From c796d84fca48feea91ca3e85fbf38e16f764a468 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Sun, 16 Apr 2017 20:46:52 +0200 Subject: [PATCH] Ignore empty lines in excludes file Closes #915 --- src/cmds/restic/cmd_backup.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/cmds/restic/cmd_backup.go b/src/cmds/restic/cmd_backup.go index 16d596a44..df36b6fd7 100644 --- a/src/cmds/restic/cmd_backup.go +++ b/src/cmds/restic/cmd_backup.go @@ -415,11 +415,20 @@ func runBackup(opts BackupOptions, gopts GlobalOptions, args []string) error { scanner := bufio.NewScanner(file) for scanner.Scan() { - line := scanner.Text() - if !strings.HasPrefix(line, "#") { - line = os.ExpandEnv(line) - opts.Excludes = append(opts.Excludes, line) + line := strings.TrimSpace(scanner.Text()) + + // ignore empty lines + if line == "" { + continue } + + // strip comments + if strings.HasPrefix(line, "#") { + continue + } + + line = os.ExpandEnv(line) + opts.Excludes = append(opts.Excludes, line) } }