Skip to content

London | 26-SDC-Mar | Khilola Rustamova| Sprint 3 |implementing shell tools #485

Open
HilolaRustam wants to merge 2 commits intoCodeYourFuture:mainfrom
HilolaRustam:implement-shell-tools
Open

London | 26-SDC-Mar | Khilola Rustamova| Sprint 3 |implementing shell tools #485
HilolaRustam wants to merge 2 commits intoCodeYourFuture:mainfrom
HilolaRustam:implement-shell-tools

Conversation

@HilolaRustam
Copy link
Copy Markdown

Learners, PR Template

Self checklist

  • I have titled my PR with Region | Cohort | FirstName LastName | Sprint | Assignment Title
  • My changes meet the requirements of the task
  • I have tested my changes
  • My changes follow the style guide

Changelist

Implementing shell tools for cat, ls and wc is complete.

Questions

@HilolaRustam HilolaRustam added 📅 Sprint 3 Assigned during Sprint 3 of this module Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Apr 10, 2026
Copy link
Copy Markdown
Member

@illicitonion illicitonion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is impressive (bash is hard!), but the exercise here was to implement the tools in javascript not in bash - can you take another look? :)

@illicitonion illicitonion added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Apr 21, 2026
@HilolaRustam HilolaRustam added Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. and removed Reviewed Volunteer to add when completing a review with trainee action still to take. labels Apr 24, 2026
Copy link
Copy Markdown
Member

@illicitonion illicitonion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is generally looking good, but a few things to look at :) Well done!

let numberLines = false;
let numberNonEmpty = false;

if (args[0] === "-n") {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would happen if someone passed both flags (e.g. node my-cat.js -b -n /some/file)? What do you think should happen?

const lines = content.split(/\r?\n/);


if (numberLines){
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code is a bit repetitive - in both the numberLines case and the numberNonEmpty case you have the same code adding a prefix and incrementing the count.

Can you think how to avoid this, so we can see more easily what's the same between each branch, and what the differences are?

Comment on lines +38 to +40
} else {
console.log(content);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines aren't indented correctly

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I ran ls -1 -a sample-files vs node my-ls.js -1 -a sample-files I saw slightly different output - can you check what's causing the difference?

Comment on lines +40 to +48
if (flag === "-l") {
console.log(`${lines} ${file}`);
} else if (flag === "-w") {
console.log(`${words} ${file}`);
} else if (flag === "-c") {
console.log(`${chars} ${file}`);
} else {
console.log(`${lines} ${words} ${chars} ${file}`);
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works if you specify exactly one flag, but the real wc supports multiple flags at the same time, e.g. wc -w -l /some/file - can you support this too?

}

if (files.length > 1) {
if (flag === "-l") {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is quite repetitive with the per-file printing - can you avoid that duplication?

@illicitonion illicitonion added Reviewed Volunteer to add when completing a review with trainee action still to take. and removed Needs Review Trainee to add when requesting review. PRs without this label will not be reviewed. labels Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Reviewed Volunteer to add when completing a review with trainee action still to take. 📅 Sprint 3 Assigned during Sprint 3 of this module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants