Browse Source

feat(set-internal-vars): add subject, test and solution for the exercise

pull/1684/head
miguel 2 years ago committed by MSilva95
parent
commit
9a75202406
  1. 11
      sh/tests/set-internal-vars_test.sh
  2. 8
      sh/tests/solutions/set-internal-vars.sh
  3. 32
      subjects/devops/set-internal-vars/README.md

11
sh/tests/set-internal-vars_test.sh

@ -0,0 +1,11 @@
#!/usr/bin/env bash
# Unofficial Bash Strict Mode
set -euo pipefail
IFS='
'
submitted=$(bash student/set-internal-vars.sh)
expected=$(bash solutions/set-internal-vars.sh)
diff <(echo "$submitted") <(echo "$expected")

8
sh/tests/solutions/set-internal-vars.sh

@ -0,0 +1,8 @@
MY_MESSAGE="Hello World"
MY_NUM=100
MY_PI=3.142
MY_ARR=(one, two, three, four, five)
echo $MY_MESSAGE
echo $MY_NUM
echo $MY_PI
echo ${MY_ARR[*]}

32
subjects/devops/set-internal-vars/README.md

@ -0,0 +1,32 @@
## set-internal-vars
### Instructions
Create a script `set-internal-vars.sh`, which will allow you to create and print the following variables.
- `MY_MESSAGE` which contains the string `"Hello World"`.
- `MY_NUM` which contains the number `100`.
- `MY_PI` which contains the number `3.142`.
- `MY_ARR` which contains `(one two three four five)`
Expected output:
```console
$ ./set-internal-vars.sh
Hello World
100
3.142
one, two, three, four, five
$
```
### Hints
Creating variables:
Variables can be created either at the shell or in shell-scripts. Any variable created within a shell script is lost when the script stops executing. A variable created at the prompt, however, will remain in existence until the shell is terminated. The syntax for creating a variable is :
`<variable name>=<value>`
> 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!
Loading…
Cancel
Save