Expand Glob (wildcards character) in paths in file in --files-from

This commit is contained in:
Stefano Fancello 2018-07-18 18:26:24 +02:00 committed by Alexander Neumann
parent 0c0a8e3d2b
commit e2da0a416c
1 changed files with 13 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import (
"context"
"io/ioutil"
"os"
"path/filepath"
"strconv"
"strings"
"time"
@ -301,10 +302,21 @@ func collectTargets(opts BackupOptions, args []string) (targets []string, err er
return nil, err
}
// expand wildcards
var lines []string
for _, line := range fromfile {
var expanded []string
expanded, err := filepath.Glob(line)
if err != nil {
return nil, err
}
lines = append(lines, expanded...)
}
// merge files from files-from into normal args so we can reuse the normal
// args checks and have the ability to use both files-from and args at the
// same time
args = append(args, fromfile...)
args = append(args, lines...)
if len(args) == 0 && !opts.Stdin {
return nil, errors.Fatal("nothing to backup, please specify target files/dirs")
}