Browse Source

feat(hard-perms): add subject, test and solution for the exercise

DEV-4049-remove-alcohol-terminology
miguel 2 years ago committed by MSilva95
parent
commit
9b975fdf0f
  1. 0
      sh/tests/hard-perm/1
  2. 0
      sh/tests/hard-perm/2
  3. 0
      sh/tests/hard-perm/4
  4. 0
      sh/tests/hard-perm/5
  5. 0
      sh/tests/hard-perm/6
  6. 0
      sh/tests/hard-perm/7
  7. 0
      sh/tests/hard-perm/8
  8. 0
      sh/tests/hard-perm/9
  9. 16
      sh/tests/hard-perm_test.sh
  10. 1
      sh/tests/solutions/hard-perm.sh
  11. 51
      subjects/devops/hard-perm/README.md

16
sh/tests/hard-perm_test.sh

@ -0,0 +1,16 @@
#!/usr/bin/env bash
# Unofficial Bash Strict Mode
set -euo pipefail
IFS='
'
script_dirS=$(cd -P "$(dirname "$BASH_SOURCE")" &>/dev/null && pwd)
challenge() {
submitted=$(ls -l "$1" && bash "$script_dirS"/student/hard-perm.sh)
expected=$(ls -l "$1" && bash "$script_dirS"/solutions/hard-perm.sh)
diff <(echo "$submitted") <(echo "$expected")
}
challenge hard-perm/

1
sh/tests/solutions/hard-perm.sh

@ -0,0 +1 @@
chmod 401 hard-perm/0 hard-perm/A && chmod 402 hard-perm/1 hard-perm/9 && chmod 604 hard-perm/2 hard-perm/8 && chmod 777 hard-perm/3 && chmod 510 hard-perm/4 hard-perm/7 && chmod 460 hard-perm/5 hard-perm/6

51
subjects/devops/hard-perm/README.md

@ -0,0 +1,51 @@
## hard-perm
### Instructions
Create a file `hard-perm.sh`, which will change the default permissions for the files and folders inside the folder `hard-perms`, to the ones bellow:
Right now the folder looks like this:
```console
$ ls -l hard-perm
total 12
drwxrwxr-x 2 user user 4096 dez 13 18:10 0
-rw-rw-r-- 1 user user 0 dez 13 18:11 1
-rw-rw-r-- 1 user user 0 dez 13 18:11 2
drwxrwxr-x 2 user user 4096 dez 13 18:10 3
-rw-rw-r-- 1 user user 0 dez 13 18:11 4
-rw-rw-r-- 1 user user 0 dez 13 18:11 5
-rw-rw-r-- 1 user user 0 dez 13 18:11 6
-rw-rw-r-- 1 user user 0 dez 13 18:11 7
-rw-rw-r-- 1 user user 0 dez 13 18:11 8
-rw-rw-r-- 1 user user 0 dez 13 18:11 9
drwxrwxr-x 2 user user 4096 dez 13 18:10 A
```
Expected output:
```console
$ ls -l hard-perm
total 12
dr-------x 2 user user 4096 dez 13 17:50 0
-r------w- 1 user user 0 dez 13 17:51 1
-rw----r-- 1 user user 0 dez 13 17:51 2
drwxrwxrwx 2 user user 4096 dez 13 17:51 3
-r-x--x--- 1 user user 0 dez 13 17:51 4
-r--rw---- 1 user user 0 dez 13 17:51 5
-r--rw---- 1 user user 0 dez 13 17:51 6
-r-x--x--- 1 user user 0 dez 13 17:51 7
-rw----r-- 1 user user 0 dez 13 17:51 8
-r------w- 1 user user 0 dez 13 17:51 9
dr-------x 2 user user 4096 dez 13 17:50 A
```
### Hints
> 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!
### References
- [Chmod](https://www.linode.com/docs/guides/modify-file-permissions-with-chmod/#modify-file-permissions-with-chmod)
Loading…
Cancel
Save