Fix directory exist logic
parent
cbaceb03ce
commit
1e3d3a211d
12
cdhist.go
12
cdhist.go
|
|
@ -103,17 +103,21 @@ func DirAliases(aliasFile string) map[string]string {
|
|||
|
||||
func cd(histFile, aliasFile, outString, path string) {
|
||||
cleanPath, err := dir.Sanitize(path)
|
||||
if err != nil {
|
||||
log.Printf("%s: %s", path, err)
|
||||
os.Exit(3)
|
||||
}
|
||||
|
||||
if ! dir.Exist(cleanPath) {
|
||||
a := DirAliases(aliasFile)
|
||||
p, prs := a[path]
|
||||
if prs {
|
||||
cleanPath, err = dir.Sanitize(p)
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
log.Printf("%s: %s", path, err)
|
||||
} else {
|
||||
log.Printf("No such directory: %s", cleanPath)
|
||||
os.Exit(3)
|
||||
}
|
||||
}
|
||||
histAdd(histFile, cleanPath)
|
||||
fmt.Printf("%s %s", outString, cleanPath)
|
||||
os.Exit(0)
|
||||
|
|
|
|||
Loading…
Reference in New Issue