Repository navigation
London | 26-SDC-Nov | Alina Sofragiu | Sprint 3 | Implement shell tools - #719
sofragiualina wants to merge 1 commit into
Conversation
| } | ||
|
|
||
| const lines = contents.toString("utf8").match(/[^\n]*\n|[^\n]+$/g) ?? []; | ||
| let lineNumber = 1; |
There was a problem hiding this comment.
How should line numbering behave across two files that cat -n prints as one stream?
To "like" or "dislike" this comment, please follow this link
There was a problem hiding this comment.
The numbering should carry on across both files. If the first file doesn’t end with a newline, the second file’s text continues on the same numbered line.
| allowPositionals: true, | ||
| }); | ||
|
|
||
| for (const file of files) { |
There was a problem hiding this comment.
What does cat output when it receives no filenames, such as in a pipeline?
To "like" or "dislike" this comment, please follow this link
There was a problem hiding this comment.
With no filenames, cat reads from standard input and prints what it receives. In a pipeline, that’s the output from the previous command. My version currently prints nothing because the file loop never runs.
| console.log(`${formattedCounts} ${label}`); | ||
| } | ||
|
|
||
| for (const file of files) { |
There was a problem hiding this comment.
What counts does wc produce when it receives piped input without any filenames?
To "like" or "dislike" this comment, please follow this link
There was a problem hiding this comment.
wc reads from standard input when I give it no filenames. By default it prints the line, word, and byte counts. My version prints nothing because the file loop never runs.
|
The CYF AI review has left comments. It will only review a PR one time. When you have addressed these comments, please request review again and a volunteer will take a look. |
…dling
Learners, PR Template
Self checklist
Task code
CYF-1150
Changelist
Completed by implementing cat, ls, and wc in JavaScript with Node.js. I used import and Node’s built-in parseArgs to handle command-line flags.