Browse Source

docs(input-redirection): fix naming inconsistencies

DEV-4397-piscine-ai-missing-file-for-ex-7-of-nlp
Michele Sessa 1 year ago committed by Michele
parent
commit
ed054578b9
  1. 8
      sh/tests/input-redirection_test.sh
  2. 2
      sh/tests/solutions/input-redirection.sh
  3. 18
      subjects/devops/input-redirection/README.md

8
sh/tests/input-redirection_test.sh

@ -8,11 +8,11 @@ script_dirS=$(cd -P "$(dirname "$BASH_SOURCE")" &>/dev/null && pwd)
challenge() { challenge() {
$(bash "$script_dirS"/student/input-redirection.sh) $(bash "$script_dirS"/student/input-redirection.sh)
submitted=$(bash "$script_dirS"/show_info.sh) submitted=$(bash "$script_dirS"/show-info.sh)
rm show_info.sh rm show-info.sh
$(bash "$script_dirS"/solutions/input-redirection.sh) $(bash "$script_dirS"/solutions/input-redirection.sh)
expected=$(bash "$script_dirS"/show_info.sh) expected=$(bash "$script_dirS"/show-info.sh)
rm show_info.sh rm show-info.sh
diff <(echo "$submitted") <(echo "$expected") diff <(echo "$submitted") <(echo "$expected")
} }

2
sh/tests/solutions/input-redirection.sh

@ -10,4 +10,4 @@ The current directory is: $PWD
The default paths are: $PATH The default paths are: $PATH
The current user is: $USERNAME The current user is: $USERNAME
EOF EOF
" > show_info.sh " > show-info.sh

18
subjects/devops/input-redirection/README.md

@ -3,11 +3,11 @@
### Instructions ### Instructions
In this exercise you will make a script `input-redirection.sh`. In this exercise you will make a script `input-redirection.sh`.
This script will read from an here document (`HereDoc`). This script will read from an here document (`heredoc`).
Usually this technique is used to programmatically generate scripts or configuration files receiving some multiline input. Usually this technique is used to programmatically generate scripts or configuration files receiving some multiline input.
The script will create a file `show_info.sh` that will run the command `cat` with `-e` as argument. The script will create a file `show-info.sh` that will run the command `cat` with `-e` as argument.
The input to `cat` will be passed using `HereDoc`. Running `show_info.sh` will output some useful information about three common environment variables. The input to `cat` will be passed using `heredoc`. Running `show-info.sh` will output some useful information about three common environment variables.
> The environment variables are `PWD`, `PATH` and `USERNAME`. > The environment variables are `PWD`, `PATH` and `USERNAME`.
@ -16,14 +16,14 @@ The input to `cat` will be passed using `HereDoc`. Running `show_info.sh` will o
- First generate the script programmatically: - First generate the script programmatically:
```console ```console
$ ./input_redirection.sh $ ./input-redirection.sh
$ $
``` ```
- Then run the generated script: - Then run the generated script:
```console ```console
$ ./show_info.sh $ bash ./show-info.sh
The current directory is: current/path/example$ The current directory is: current/path/example$
The default paths are: /first_path:/second_path:/third_path$ The default paths are: /first_path:/second_path:/third_path$
The current user is: your_name$ The current user is: your_name$
@ -34,12 +34,12 @@ $
You will need to mix more than one redirection tool: You will need to mix more than one redirection tool:
- `>` will be useful to create `show_info.sh`. - `>` will be useful to create `show-info.sh`.
- `<<` is the `HereDoc` redirection. - `<<` is the `heredoc` redirection.
- To start playing with `HereDoc` you can try `wc -l <<EOF`, type some random things, then write `EOF` on a new line and press `Enter`. - To start playing with `heredoc` you can try `wc -l <<EOF`, type some random things, then write `EOF` on a new line and press `Enter`.
- Don't forget you can use `echo` to write into `show_info.sh`. - Don't forget you can use `echo` to write into `show-info.sh`.
> You have to use Man or Google to know more about commands flags, in order to solve this exercise! > You have to use Man or Google to know more about commands flags, in order to solve this exercise!
> Google and Man will be your friends! > Google and Man will be your friends!

Loading…
Cancel
Save