diff --git a/concepts/commands-and-arguments/about.md b/concepts/commands-and-arguments/about.md index a8051ced..bbed68b7 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. +* `#` 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 8c110b82..3a0d082e 100644 --- a/concepts/commands-and-arguments/introduction.md +++ b/concepts/commands-and-arguments/introduction.md @@ -29,9 +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. -Comments exist for humans reading the script. +`#` 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. +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/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..b900c0c0 100644 --- a/exercises/concept/shopping/.docs/introduction.md +++ b/exercises/concept/shopping/.docs/introduction.md @@ -31,9 +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. -Comments exist for humans reading the script. +`#` 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. +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/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