Ensure "existingfile" doesn't choke on "-".

This commit is contained in:
Alec Thomas
2020-04-27 09:10:44 +10:00
parent 407c8229a6
commit 51a1ea979a
+9 -7
View File
@@ -555,13 +555,15 @@ func existingFileMapper(r *Registry) MapperFunc {
if err != nil {
return err
}
path = ExpandPath(path)
stat, err := os.Stat(path)
if err != nil {
return err
}
if stat.IsDir() {
return errors.Errorf("%q exists but is a directory", path)
if path != "-" {
path = ExpandPath(path)
stat, err := os.Stat(path)
if err != nil {
return err
}
if stat.IsDir() {
return errors.Errorf("%q exists but is a directory", path)
}
}
target.SetString(path)
return nil