Read password without trailing \n (newline)

This commit is contained in:
Martin Puppe 2020-03-25 18:47:35 +01:00
parent 95d13588ba
commit 3a9c1d106f

View file

@ -39,7 +39,7 @@ def do_backup(config)
puts "Repository: #{ENV['RESTIC_REPOSITORY']}" puts "Repository: #{ENV['RESTIC_REPOSITORY']}"
if config['password-file'] if config['password-file']
puts "Reading password from file #{config['password-file']} …" puts "Reading password from file #{config['password-file']} …"
ENV['RESTIC_PASSWORD'] = File.open(config['password-file']) {|f| f.readline} ENV['RESTIC_PASSWORD'] = File.open(config['password-file'], &:gets).chomp
else else
ENV['RESTIC_PASSWORD'] = STDIN.getpass('Please put in your restic password: ') ENV['RESTIC_PASSWORD'] = STDIN.getpass('Please put in your restic password: ')
end end