Skip to content

Commit 667e3bb

Browse files
committed
clean up
1 parent 1a27139 commit 667e3bb

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

  • implement-shell-tools/ls

implement-shell-tools/ls/ls.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,20 @@ const flags = new Set();
77
let paths = [];
88

99
let isFlag = true;
10-
for (let i = 0; i < args.length; i++) {
11-
if (isFlag && args[i] === "--") {
10+
for (const arg of args) {
11+
if (isFlag && arg === "--") {
1212
isFlag = false;
13-
} else if (isFlag && args[i].startsWith("-") && args[i] !== "-") {
13+
} else if (isFlag && arg.startsWith("-") && arg !== "-") {
1414
// capture the flags without the -
1515
// supports combined flags like -1a
16-
for (const ch of args[i].slice(1)) {
16+
for (const ch of arg.slice(1)) {
1717
flags.add(ch);
1818
}
1919
} else {
20-
paths.push(args[i]);
20+
paths.push(arg);
2121
}
2222
}
2323

24-
console.log(paths);
25-
2624
if (paths.length === 0) {
2725
paths.push(".");
2826
}

0 commit comments

Comments
 (0)