From c9687539f478462ee841906d806c7fc1fe88fdb2 Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Fri, 27 Dec 2024 11:29:57 +0000 Subject: [PATCH 1/2] Add exercises to implement shell tools These exercises are language-agnostic - the same description and test files work for any language. In sprint 3 we will set implementing these in JS, and in sprint 4 we will set implementing these in Python. --- .gitignore | 1 + implement-shell-tools/README.md | 9 +++++++++ implement-shell-tools/cat/README.md | 17 +++++++++++++++++ implement-shell-tools/cat/sample-files/1.txt | 1 + implement-shell-tools/cat/sample-files/2.txt | 1 + implement-shell-tools/cat/sample-files/3.txt | 5 +++++ implement-shell-tools/ls/README.md | 15 +++++++++++++++ .../ls/sample-files/.hidden.txt | 0 implement-shell-tools/ls/sample-files/1.txt | 1 + implement-shell-tools/ls/sample-files/2.txt | 1 + implement-shell-tools/ls/sample-files/3.txt | 5 +++++ implement-shell-tools/ls/sample-files/dir/a.txt | 0 implement-shell-tools/ls/sample-files/dir/b.txt | 0 .../ls/sample-files/dir/subdir/x.txt | 0 .../ls/sample-files/dir/subdir/y.txt | 0 .../ls/sample-files/dir/subdir/z.txt | 0 implement-shell-tools/wc/README.md | 17 +++++++++++++++++ implement-shell-tools/wc/sample-files/1.txt | 1 + implement-shell-tools/wc/sample-files/2.txt | 1 + implement-shell-tools/wc/sample-files/3.txt | 5 +++++ 20 files changed, 80 insertions(+) create mode 100644 .gitignore create mode 100644 implement-shell-tools/README.md create mode 100644 implement-shell-tools/cat/README.md create mode 100644 implement-shell-tools/cat/sample-files/1.txt create mode 100644 implement-shell-tools/cat/sample-files/2.txt create mode 100644 implement-shell-tools/cat/sample-files/3.txt create mode 100644 implement-shell-tools/ls/README.md create mode 100644 implement-shell-tools/ls/sample-files/.hidden.txt create mode 100644 implement-shell-tools/ls/sample-files/1.txt create mode 100644 implement-shell-tools/ls/sample-files/2.txt create mode 100644 implement-shell-tools/ls/sample-files/3.txt create mode 100644 implement-shell-tools/ls/sample-files/dir/a.txt create mode 100644 implement-shell-tools/ls/sample-files/dir/b.txt create mode 100644 implement-shell-tools/ls/sample-files/dir/subdir/x.txt create mode 100644 implement-shell-tools/ls/sample-files/dir/subdir/y.txt create mode 100644 implement-shell-tools/ls/sample-files/dir/subdir/z.txt create mode 100644 implement-shell-tools/wc/README.md create mode 100644 implement-shell-tools/wc/sample-files/1.txt create mode 100644 implement-shell-tools/wc/sample-files/2.txt create mode 100644 implement-shell-tools/wc/sample-files/3.txt diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/implement-shell-tools/README.md b/implement-shell-tools/README.md new file mode 100644 index 0000000..1a2f480 --- /dev/null +++ b/implement-shell-tools/README.md @@ -0,0 +1,9 @@ +# Implement shell tools + +Your task is to re-implement shell tools you have used. + +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. diff --git a/implement-shell-tools/cat/README.md b/implement-shell-tools/cat/README.md new file mode 100644 index 0000000..7284a5e --- /dev/null +++ b/implement-shell-tools/cat/README.md @@ -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`. diff --git a/implement-shell-tools/cat/sample-files/1.txt b/implement-shell-tools/cat/sample-files/1.txt new file mode 100644 index 0000000..ed7bf7d --- /dev/null +++ b/implement-shell-tools/cat/sample-files/1.txt @@ -0,0 +1 @@ +Once upon a time... diff --git a/implement-shell-tools/cat/sample-files/2.txt b/implement-shell-tools/cat/sample-files/2.txt new file mode 100644 index 0000000..c2b8f0d --- /dev/null +++ b/implement-shell-tools/cat/sample-files/2.txt @@ -0,0 +1 @@ +There was a house made of gingerbread. diff --git a/implement-shell-tools/cat/sample-files/3.txt b/implement-shell-tools/cat/sample-files/3.txt new file mode 100644 index 0000000..cdba099 --- /dev/null +++ b/implement-shell-tools/cat/sample-files/3.txt @@ -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... diff --git a/implement-shell-tools/ls/README.md b/implement-shell-tools/ls/README.md new file mode 100644 index 0000000..edbfb81 --- /dev/null +++ b/implement-shell-tools/ls/README.md @@ -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`. diff --git a/implement-shell-tools/ls/sample-files/.hidden.txt b/implement-shell-tools/ls/sample-files/.hidden.txt new file mode 100644 index 0000000..e69de29 diff --git a/implement-shell-tools/ls/sample-files/1.txt b/implement-shell-tools/ls/sample-files/1.txt new file mode 100644 index 0000000..ed7bf7d --- /dev/null +++ b/implement-shell-tools/ls/sample-files/1.txt @@ -0,0 +1 @@ +Once upon a time... diff --git a/implement-shell-tools/ls/sample-files/2.txt b/implement-shell-tools/ls/sample-files/2.txt new file mode 100644 index 0000000..c2b8f0d --- /dev/null +++ b/implement-shell-tools/ls/sample-files/2.txt @@ -0,0 +1 @@ +There was a house made of gingerbread. diff --git a/implement-shell-tools/ls/sample-files/3.txt b/implement-shell-tools/ls/sample-files/3.txt new file mode 100644 index 0000000..cdba099 --- /dev/null +++ b/implement-shell-tools/ls/sample-files/3.txt @@ -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... diff --git a/implement-shell-tools/ls/sample-files/dir/a.txt b/implement-shell-tools/ls/sample-files/dir/a.txt new file mode 100644 index 0000000..e69de29 diff --git a/implement-shell-tools/ls/sample-files/dir/b.txt b/implement-shell-tools/ls/sample-files/dir/b.txt new file mode 100644 index 0000000..e69de29 diff --git a/implement-shell-tools/ls/sample-files/dir/subdir/x.txt b/implement-shell-tools/ls/sample-files/dir/subdir/x.txt new file mode 100644 index 0000000..e69de29 diff --git a/implement-shell-tools/ls/sample-files/dir/subdir/y.txt b/implement-shell-tools/ls/sample-files/dir/subdir/y.txt new file mode 100644 index 0000000..e69de29 diff --git a/implement-shell-tools/ls/sample-files/dir/subdir/z.txt b/implement-shell-tools/ls/sample-files/dir/subdir/z.txt new file mode 100644 index 0000000..e69de29 diff --git a/implement-shell-tools/wc/README.md b/implement-shell-tools/wc/README.md new file mode 100644 index 0000000..bd76b65 --- /dev/null +++ b/implement-shell-tools/wc/README.md @@ -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. diff --git a/implement-shell-tools/wc/sample-files/1.txt b/implement-shell-tools/wc/sample-files/1.txt new file mode 100644 index 0000000..ed7bf7d --- /dev/null +++ b/implement-shell-tools/wc/sample-files/1.txt @@ -0,0 +1 @@ +Once upon a time... diff --git a/implement-shell-tools/wc/sample-files/2.txt b/implement-shell-tools/wc/sample-files/2.txt new file mode 100644 index 0000000..c2b8f0d --- /dev/null +++ b/implement-shell-tools/wc/sample-files/2.txt @@ -0,0 +1 @@ +There was a house made of gingerbread. diff --git a/implement-shell-tools/wc/sample-files/3.txt b/implement-shell-tools/wc/sample-files/3.txt new file mode 100644 index 0000000..cdba099 --- /dev/null +++ b/implement-shell-tools/wc/sample-files/3.txt @@ -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... From 3eb4b7197e26a48ed9d8d0506c508baab7f3959b Mon Sep 17 00:00:00 2001 From: Daniel Wagner-Hall Date: Thu, 30 Jan 2025 10:48:05 +0000 Subject: [PATCH 2/2] Note about interpreter prefixes --- implement-shell-tools/README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/implement-shell-tools/README.md b/implement-shell-tools/README.md index 1a2f480..18666d2 100644 --- a/implement-shell-tools/README.md +++ b/implement-shell-tools/README.md @@ -7,3 +7,5 @@ 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`.