forked from TrueCloudLab/restic
Expand Glob (wildcards character) in paths in file in --files-from
This commit is contained in:
parent
0c0a8e3d2b
commit
e2da0a416c
1 changed files with 13 additions and 1 deletions
|
@ -6,6 +6,7 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
@ -301,10 +302,21 @@ func collectTargets(opts BackupOptions, args []string) (targets []string, err er
|
||||||
return nil, err
|
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
|
// 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
|
// args checks and have the ability to use both files-from and args at the
|
||||||
// same time
|
// same time
|
||||||
args = append(args, fromfile...)
|
args = append(args, lines...)
|
||||||
if len(args) == 0 && !opts.Stdin {
|
if len(args) == 0 && !opts.Stdin {
|
||||||
return nil, errors.Fatal("nothing to backup, please specify target files/dirs")
|
return nil, errors.Fatal("nothing to backup, please specify target files/dirs")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue