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 287fd3a commit d8c098fCopy full SHA for d8c098f
implement-shell-tools/cat/cat.mjs
@@ -13,6 +13,9 @@ program.parse();
13
const options = program.opts();
14
const paths = program.args;
15
16
+const numNonBlank = options.b;
17
+const numAll = !!options.n && !numNonBlank;
18
+
19
let hadError = false;
20
for(const path of paths){
21
let content;
@@ -29,14 +32,14 @@ for(const path of paths){
29
32
let lineNum = 1;
30
33
31
34
for (const line of lines){
- if(options.b){
35
+ if(numNonBlank){
36
if(line.trim() !== ""){
37
console.log(`${lineNum.toString().padStart(5)} ${line}`)
38
lineNum++;
39
} else {
40
console.log("");
41
}
- } else if(options.n){
42
+ } else if(numAll){
43
44
45
} else{
0 commit comments