Skip to content

Commit 997dc07

Browse files
committed
fixing the indintation and changin the gap to be cat tab symbol instead of spaces
1 parent bc95366 commit 997dc07

1 file changed

Lines changed: 13 additions & 16 deletions

File tree

  • implement-shell-tools/cat

implement-shell-tools/cat/cat.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ const fs = require("fs");
33
const args = process.argv.slice(2);
44

55
let flag = "";
6-
let lineNumber = 1;
76

87
for (const arg of args) {
98

@@ -12,7 +11,7 @@ for (const arg of args) {
1211
flag = arg;
1312
continue;
1413
}
15-
let lineNumber = 1;
14+
let lineNumber = 1;
1615
// Read the file
1716
const content = fs.readFileSync(arg, "utf8");
1817

@@ -24,22 +23,20 @@ for (const arg of args) {
2423
lines.pop();
2524
}
2625

27-
28-
for (const line of lines) {
2926

30-
if (flag === "-n") {
31-
console.log(`${String(lineNumber).padStart(6)} ${line}`);;
32-
lineNumber++;
33-
} else if (flag === "-b") {
34-
if (line === "") {
35-
console.log("");
36-
} else {
37-
console.log(`${String(lineNumber).padStart(6)} ${line}`);;
38-
lineNumber++;
39-
}
40-
}
27+
for (const line of lines) {
4128

42-
else {
29+
if (flag === "-n") {
30+
console.log(`${String(lineNumber).padStart(6)} ${line}`);;
31+
lineNumber++;
32+
} else if (flag === "-b") {
33+
if (line === "") {
34+
console.log("");
35+
} else {
36+
console.log(`${String(lineNumber).padStart(6)}\t${line}`);
37+
lineNumber++;
38+
}
39+
} else {
4340
console.log(line);
4441
}
4542
}

0 commit comments

Comments
 (0)