From c5217492d374824891e8ce4686470082f39ac0ef Mon Sep 17 00:00:00 2001 From: Glenn Jackman Date: Sat, 5 Dec 2026 08:13:23 -0500 Subject: [PATCH 1/3] Tighten shopping tests and clarify comment syntax Check that task 2 counts the given file, use a filename with spaces so unquoted expansions fail, explain that # only starts a comment at the start of a word, and fix a typo. Co-Authored-By: Claude Sonnet 5.5 --- concepts/commands-and-arguments/about.md | 5 +++-- concepts/commands-and-arguments/introduction.md | 5 +++-- exercises/concept/shopping/.docs/instructions.md | 2 +- exercises/concept/shopping/.docs/introduction.md | 5 +++-- exercises/concept/shopping/shopping.bats | 13 ++++++++++++- 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/concepts/commands-and-arguments/about.md b/concepts/commands-and-arguments/about.md index a8051ced..5edcf479 100644 --- a/concepts/commands-and-arguments/about.md +++ b/concepts/commands-and-arguments/about.md @@ -45,8 +45,9 @@ All the remaining words become _arguments_ to that command (options, filenames, ~~~~exercism/note In the examples below, we'll show you some interactive commands that you can run. -* The `#` character starts a _comment_. - Any words following the `#` are ignored by the shell; the comment is meant only for reading. +* A word beginning with `#` starts a _comment_. + The shell ignores everything from the `#` to the end of the line; the comment is meant only for reading. + A `#` inside a word does not start a comment: `echo a#b` prints `a#b`. * The `$` character denotes a shell prompt. If you're copying the command, do not include the prompt. ~~~~ diff --git a/concepts/commands-and-arguments/introduction.md b/concepts/commands-and-arguments/introduction.md index 8c110b82..5eb20702 100644 --- a/concepts/commands-and-arguments/introduction.md +++ b/concepts/commands-and-arguments/introduction.md @@ -29,8 +29,9 @@ Bash is "sh-compatible" and can run most `sh` scripts, but some bash features wi ## Comments -A line beginning with `#` is a _comment_, and bash ignores it. -A comment can also follow a command on the same line: everything from the `#` to the end of the line is ignored. +A word beginning with `#` starts a _comment_: bash ignores everything from the `#` to the end of the line. +A comment can be on its own line, or it can follow a command on the same line. +A `#` inside a word does not start a comment: `echo a#b` prints `a#b`. Comments exist for humans reading the script. ## Words and arguments diff --git a/exercises/concept/shopping/.docs/instructions.md b/exercises/concept/shopping/.docs/instructions.md index c9e03794..bd5efb3f 100644 --- a/exercises/concept/shopping/.docs/instructions.md +++ b/exercises/concept/shopping/.docs/instructions.md @@ -17,7 +17,7 @@ bash shopping.sh shopping-list.txt ## 1. Print the shopping list name -Use `head`, `awk`, or `sed` (or any other tool you are familar with) to print only the first line of `"$shopping_list_file"`. +Use `head`, `awk`, or `sed` (or any other tool you are familiar with) to print only the first line of `"$shopping_list_file"`. Read the name from the file instead of printing a hard-coded name with `echo`. You do not need to learn these tools in depth for this exercise; the hints provide suitable commands. diff --git a/exercises/concept/shopping/.docs/introduction.md b/exercises/concept/shopping/.docs/introduction.md index f32652c8..3909f2ed 100644 --- a/exercises/concept/shopping/.docs/introduction.md +++ b/exercises/concept/shopping/.docs/introduction.md @@ -31,8 +31,9 @@ Bash is "sh-compatible" and can run most `sh` scripts, but some bash features wi ### Comments -A line beginning with `#` is a _comment_, and bash ignores it. -A comment can also follow a command on the same line: everything from the `#` to the end of the line is ignored. +A word beginning with `#` starts a _comment_: bash ignores everything from the `#` to the end of the line. +A comment can be on its own line, or it can follow a command on the same line. +A `#` inside a word does not start a comment: `echo a#b` prints `a#b`. Comments exist for humans reading the script. ### Words and arguments diff --git a/exercises/concept/shopping/shopping.bats b/exercises/concept/shopping/shopping.bats index 31769fb6..fdb00db3 100644 --- a/exercises/concept/shopping/shopping.bats +++ b/exercises/concept/shopping/shopping.bats @@ -15,7 +15,7 @@ test_print_shopping_list_name() { # @test # bats test_tags=task:1 test_read_shopping_list_name_from_file() { # @test - list_file="${BATS_TEST_TMPDIR}/different-shopping-list.txt" + list_file="${BATS_TEST_TMPDIR}/different shopping list.txt" printf 'A different shopping list\n' > "$list_file" run --keep-empty-lines bash shopping.sh "$list_file" @@ -35,6 +35,17 @@ test_count_shopping_list_lines() { # @test assert_line --index 2 --regexp '^[[:space:]]*21[[:space:]]+shopping-list\.txt$' } +# bats test_tags=task:2 +test_count_lines_of_given_file() { # @test + list_file="${BATS_TEST_TMPDIR}/different shopping list.txt" + printf '%s\n' 'A different shopping list' 'eggs' 'milk' > "$list_file" + + run --keep-empty-lines bash shopping.sh "$list_file" + + assert_success + assert_line --index 2 --regexp '^[[:space:]]*3[[:space:]]+.*/different shopping list\.txt$' +} + # bats test_tags=task:3 test_print_buttermilk_substitution() { # @test run bash shopping.sh shopping-list.txt From ce49d33184bd03e12115da9ded5b3c799e931be2 Mon Sep 17 00:00:00 2001 From: Glenn Jackman Date: Sat, 5 Dec 2026 13:36:03 -0500 Subject: [PATCH 2/3] Note that # can be a word by itself in comment docs Co-Authored-By: Claude Sonnet 5.5 --- concepts/commands-and-arguments/about.md | 1 + concepts/commands-and-arguments/introduction.md | 1 + exercises/concept/shopping/.docs/introduction.md | 1 + 3 files changed, 3 insertions(+) diff --git a/concepts/commands-and-arguments/about.md b/concepts/commands-and-arguments/about.md index 5edcf479..e7c150f3 100644 --- a/concepts/commands-and-arguments/about.md +++ b/concepts/commands-and-arguments/about.md @@ -46,6 +46,7 @@ All the remaining words become _arguments_ to that command (options, filenames, In the examples below, we'll show you some interactive commands that you can run. * A word beginning with `#` starts a _comment_. + The `#` can be a word by itself, as in `# like this`. The shell ignores everything from the `#` to the end of the line; the comment is meant only for reading. A `#` inside a word does not start a comment: `echo a#b` prints `a#b`. * The `$` character denotes a shell prompt. diff --git a/concepts/commands-and-arguments/introduction.md b/concepts/commands-and-arguments/introduction.md index 5eb20702..eebd069f 100644 --- a/concepts/commands-and-arguments/introduction.md +++ b/concepts/commands-and-arguments/introduction.md @@ -30,6 +30,7 @@ Bash is "sh-compatible" and can run most `sh` scripts, but some bash features wi ## Comments A word beginning with `#` starts a _comment_: bash ignores everything from the `#` to the end of the line. +The `#` can be a word by itself, as in `# like this`. A comment can be on its own line, or it can follow a command on the same line. A `#` inside a word does not start a comment: `echo a#b` prints `a#b`. Comments exist for humans reading the script. diff --git a/exercises/concept/shopping/.docs/introduction.md b/exercises/concept/shopping/.docs/introduction.md index 3909f2ed..05414d6a 100644 --- a/exercises/concept/shopping/.docs/introduction.md +++ b/exercises/concept/shopping/.docs/introduction.md @@ -32,6 +32,7 @@ Bash is "sh-compatible" and can run most `sh` scripts, but some bash features wi ### Comments A word beginning with `#` starts a _comment_: bash ignores everything from the `#` to the end of the line. +The `#` can be a word by itself, as in `# like this`. A comment can be on its own line, or it can follow a command on the same line. A `#` inside a word does not start a comment: `echo a#b` prints `a#b`. Comments exist for humans reading the script. From 5615aea8c9289415cac9b6e7abbbc3a79973e84f Mon Sep 17 00:00:00 2001 From: Glenn Jackman Date: Sat, 5 Dec 2026 16:06:16 -0500 Subject: [PATCH 3/3] Simplify the wording about comments Co-Authored-By: Claude Sonnet 5.5 --- concepts/commands-and-arguments/about.md | 7 +++---- concepts/commands-and-arguments/introduction.md | 6 ++---- exercises/concept/shopping/.docs/introduction.md | 6 ++---- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/concepts/commands-and-arguments/about.md b/concepts/commands-and-arguments/about.md index e7c150f3..bbed68b7 100644 --- a/concepts/commands-and-arguments/about.md +++ b/concepts/commands-and-arguments/about.md @@ -45,10 +45,9 @@ All the remaining words become _arguments_ to that command (options, filenames, ~~~~exercism/note In the examples below, we'll show you some interactive commands that you can run. -* A word beginning with `#` starts a _comment_. - The `#` can be a word by itself, as in `# like this`. - The shell ignores everything from the `#` to the end of the line; the comment is meant only for reading. - A `#` inside a word does not start a comment: `echo a#b` prints `a#b`. +* `#` starts a _comment_. + The shell ignores everything from the `#` to the end of the line. + The exception is a `#` _inside_ a word, which does not start a comment: `echo a#b` prints `a#b`. * The `$` character denotes a shell prompt. If you're copying the command, do not include the prompt. ~~~~ diff --git a/concepts/commands-and-arguments/introduction.md b/concepts/commands-and-arguments/introduction.md index eebd069f..3a0d082e 100644 --- a/concepts/commands-and-arguments/introduction.md +++ b/concepts/commands-and-arguments/introduction.md @@ -29,11 +29,9 @@ Bash is "sh-compatible" and can run most `sh` scripts, but some bash features wi ## Comments -A word beginning with `#` starts a _comment_: bash ignores everything from the `#` to the end of the line. -The `#` can be a word by itself, as in `# like this`. +`#` starts a _comment_: bash ignores everything from the `#` to the end of the line. A comment can be on its own line, or it can follow a command on the same line. -A `#` inside a word does not start a comment: `echo a#b` prints `a#b`. -Comments exist for humans reading the script. +The exception is a `#` _inside_ a word, which does not start a comment: `echo a#b` prints `a#b`. ## Words and arguments diff --git a/exercises/concept/shopping/.docs/introduction.md b/exercises/concept/shopping/.docs/introduction.md index 05414d6a..b900c0c0 100644 --- a/exercises/concept/shopping/.docs/introduction.md +++ b/exercises/concept/shopping/.docs/introduction.md @@ -31,11 +31,9 @@ Bash is "sh-compatible" and can run most `sh` scripts, but some bash features wi ### Comments -A word beginning with `#` starts a _comment_: bash ignores everything from the `#` to the end of the line. -The `#` can be a word by itself, as in `# like this`. +`#` starts a _comment_: bash ignores everything from the `#` to the end of the line. A comment can be on its own line, or it can follow a command on the same line. -A `#` inside a word does not start a comment: `echo a#b` prints `a#b`. -Comments exist for humans reading the script. +The exception is a `#` _inside_ a word, which does not start a comment: `echo a#b` prints `a#b`. ### Words and arguments