We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent da1d1cc commit 0a84822Copy full SHA for 0a84822
1 file changed
implement-shell-tools/cat/cat.py
@@ -30,21 +30,17 @@
30
31
for filepath in args.paths:
32
with open(filepath, "r", encoding="utf-8") as f:
33
- content = f.read()
34
-
35
- lines = content.split("\n")
36
37
- for line in lines:
38
- if args.number_all_lines:
39
- print(f"{line_number} {line}")
40
- line_number += 1
41
42
- elif args.number_non_empty_lines:
+ for line in f:
+ if args.number_non_empty_lines:
43
if line.strip() == "":
44
- print(line)
+ print(line, end="")
45
else:
46
+ print(f"{line_number} {line}", end="")
+ line_number += 1
+
+ elif args.number_all_lines:
47
line_number +=1
48
49
50
0 commit comments