File tree Expand file tree Collapse file tree
implement-shell-tools/cat Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ const fs = require("fs");
33const args = process . argv . slice ( 2 ) ;
44
55let flag = "" ;
6- let lineNumber = 1 ;
76
87for ( 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 }
You can’t perform that action at this time.
0 commit comments