Skip to content

Commit 00757b2

Browse files
committed
fix the printing bug without the -1 flag
1 parent be70047 commit 00757b2

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

  • implement-shell-tools/ls

implement-shell-tools/ls/ls.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
import argparse
33

4-
parser=argparse.ArgumentParser(prog="cat",usage="implement a simple ls python")
4+
parser=argparse.ArgumentParser(prog="ls",usage="implement a simple ls python")
55
parser.add_argument("-1",dest="one",action="store_true")
66
parser.add_argument("-a",action="store_true")
77
parser.add_argument("path",nargs="*",help="path to list files")
@@ -27,10 +27,11 @@
2727
files_list = ['.', '..'] + non_hidden + hidden
2828
else:
2929
files_list = non_hidden
30-
31-
for item in files_list :
32-
if args.one and args.a :
33-
print(item)
34-
elif args.one :
35-
if not item.startswith(".") :
30+
31+
if args.one :
32+
for item in files_list :
3633
print(item)
34+
else:
35+
print(" ".join(files_list))
36+
37+

0 commit comments

Comments
 (0)