Skip to content

Commit

Permalink
Windows root parse fix
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Dominic Della Valle <[email protected]>
  • Loading branch information
djdv committed Oct 28, 2016
1 parent 465044a commit f2b271c
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions commands/cli/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ func appendFile(fpath string, argDef *cmds.Argument, recursive, hidden bool) (fi
fpath = cwd
}

fpath = filepath.ToSlash(filepath.Clean(fpath))
fpath = filepath.Clean(fpath)

stat, err := os.Lstat(fpath)
if err != nil {
Expand All @@ -429,7 +429,13 @@ func appendFile(fpath string, argDef *cmds.Argument, recursive, hidden bool) (fi
}
}

return files.NewSerialFile(path.Base(fpath), fpath, hidden, stat)
// special case for Windows drive roots i.e. X:\
// drive path must be preserved and not converted to X: or /
if len(fpath) == 3 && fpath[0] != '/' && fpath[1:3] == `:\` {
return files.NewSerialFile(fpath, fpath, hidden, stat)
}

return files.NewSerialFile(path.Base(filepath.ToSlash(fpath)), fpath, hidden, stat)
}

// Inform the user if a file is waiting on input
Expand Down

0 comments on commit f2b271c

Please sign in to comment.