Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add exercises to implement shell tools #7

Merged
merged 2 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
11 changes: 11 additions & 0 deletions implement-shell-tools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Implement shell tools

Your task is to re-implement shell tools you have used.
illicitonion marked this conversation as resolved.
Show resolved Hide resolved

Each directory contains instructions for one shell tool to re-implement.

In general your success criteria are that the tools give the same output as the real shell tools on your computer.

You will be told in your coursework issue which language you should use in your implementation.

If the language you're using requires an interpreter, it's fine for the commands you run to be prefixed with that. i.e. if you're implementing `cat` in `NodeJS` it's fine if you need to run `node cat.js 1.txt` instead of `cat 1.txt`.
17 changes: 17 additions & 0 deletions implement-shell-tools/cat/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Implement `cat`

You should already be familiar with the `cat` command line tool.

Your task is to implement your own version of `cat`.

It must act the same as `cat` would, if run from the directory containing this README.md file, for the following command lines:

* `cat sample-files/1.txt`
* `cat -n sample-files/1.txt`
* `cat sample-files/*.txt`
* `cat -n sample-files/*.txt`
* `cat -b sample-files/3.txt`

Matching any additional behaviours or flags are optional stretch goals.

We recommend you start off supporting no flags, then add support for `-n`, then add support for `-b`.
1 change: 1 addition & 0 deletions implement-shell-tools/cat/sample-files/1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Once upon a time...
1 change: 1 addition & 0 deletions implement-shell-tools/cat/sample-files/2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
There was a house made of gingerbread.
5 changes: 5 additions & 0 deletions implement-shell-tools/cat/sample-files/3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
It looked delicious.
I was tempted to take a bite of it.
But this seemed like a bad idea...

There's more to come, though...
15 changes: 15 additions & 0 deletions implement-shell-tools/ls/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Implement `ls`

You should already be familiar with the `ls` command line tool.

Your task is to implement your own version of `ls`.

It must act the same as `ls` would, if run from the directory containing this README.md file, for the following command lines:

* `ls -1`
* `ls -1 sample-files`
* `ls -1 -a sample-files`

Matching any additional behaviours or flags are optional stretch goals.

We recommend you start off supporting just `-1`, then adding support for `-a`.
Empty file.
1 change: 1 addition & 0 deletions implement-shell-tools/ls/sample-files/1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Once upon a time...
1 change: 1 addition & 0 deletions implement-shell-tools/ls/sample-files/2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
There was a house made of gingerbread.
5 changes: 5 additions & 0 deletions implement-shell-tools/ls/sample-files/3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
It looked delicious.
I was tempted to take a bite of it.
But this seemed like a bad idea...

There's more to come, though...
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
17 changes: 17 additions & 0 deletions implement-shell-tools/wc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Implement `wc`

You should already be familiar with the `wc` command line tool.

Your task is to implement your own version of `wc`.

It must act the same as `wc` would, if run from the directory containing this README.md file, for the following command lines:

* `wc sample-files/*`
* `wc -l sample-files/3.txt`
* `wc -w sample-files/3.txt`
* `wc -c sample-files/3.txt`
* `wc -l sample-files/*`

Matching any additional behaviours or flags are optional stretch goals.

We recommend you start off supporting no flags for one file, then add support for multiple files, then add support for the flags.
1 change: 1 addition & 0 deletions implement-shell-tools/wc/sample-files/1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Once upon a time...
1 change: 1 addition & 0 deletions implement-shell-tools/wc/sample-files/2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
There was a house made of gingerbread.
5 changes: 5 additions & 0 deletions implement-shell-tools/wc/sample-files/3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
It looked delicious.
I was tempted to take a bite of it.
But this seemed like a bad idea...

There's more to come, though...