diff --git a/ls/ls.go b/ls/ls.go index 950ebf9..3fa0f2c 100644 --- a/ls/ls.go +++ b/ls/ls.go @@ -6,11 +6,6 @@ import( "strings" ) -var( - dirFlag bool - foldLvl int -) - func IsDir(p string) (bool, error) { finfo, e := os.Stat(p) if e != nil { @@ -51,22 +46,20 @@ func ls(p string, fold int) error { pp := strings.TrimRight(p, "/") - if !isDir || dirFlag || fold<1 { - fmt.Println(pp); - }else{ + if isDir && fold>0 { l, e := ReadDir(pp) if e!=nil { return e } for _, f := range l { s := pp+"/"+f.Name() - if b, _:=IsDir(s) ; b { - fmt.Println(s) - } - if 00 { + fmt.Println(f.Name()) + e := ls(f.Name(), foldLvl) + if e!=nil { + status = 1 + fmt.Fprintf(os.Stderr, "%s: %s.\n", arg0, e) + } + } else { + fmt.Println(f.Name()) } } }