Browse Source

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

pull/1684/head
miguel 2 years ago committed by MSilva95
parent
commit
88eee63db2
  1. 12
      sh/tests/easy-perm/example.txt
  2. 16
      sh/tests/easy-perm/example2.txt
  3. 16
      sh/tests/easy-perm_test.sh
  4. 1
      sh/tests/solutions/easy-perm.sh
  5. 46
      subjects/devops/easy-perm/README.md

12
sh/tests/easy-perm/example.txt

@ -0,0 +1,12 @@
Q. How did the programmer die in the shower?
A. He read the shampoo bottle instructions: Lather. Rinse. Repeat.
~~~~~~~~~~~~~~~~~~~~~~~~~
How many programmers does it take to change a light bulb?
None – It’s a hardware problem
~~~~~~~~~~~~~~~~~~~~~~~~~
Why do programmers always mix up Halloween and Christmas?
Because Oct 31 equals Dec 25.

16
sh/tests/easy-perm/example2.txt

@ -0,0 +1,16 @@
“The best TDD can do, is assure that code does what the programmer thinks it should do. That is pretty good BTW.”
“Simply put, things always had to be in a production-ready state: if you wrote it, you darn well had to be there to get it running!”
“If you think it’s expensive to hire a professional, wait until you hire an amateur.”
“Programming is not a zero-sum game. Teaching something to a fellow programmer doesn’t take it away from you.”
“A phased approach to continuous delivery is not only preferable, it’s infinitely more manageable.”
“So, what do you do?”
“I’m lean”
“What?”
“I’m agile”
“What?”
“Fine. I make websites.”

16
sh/tests/easy-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/easy-perm.sh)
expected=$(ls -l "$1" && bash "$script_dirS"/solutions/easy-perm.sh)
diff <(echo "$submitted") <(echo "$expected")
}
challenge easy-perm/

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

@ -0,0 +1 @@
chmod 644 easy-perm/example.txt && chmod 746 easy-perm/example2.txt

46
subjects/devops/easy-perm/README.md

@ -0,0 +1,46 @@
## easy-perm
### Instructions
Create a file `easy-perm.sh`, which will change the default permissions for the `example.txt` and `example2.txt` files inside the folder `easy-perms`, to the ones bellow:
Now
Expected Output:
```console
$ ls -l easy-perm
total 8
-rwxr--rw- 1 user user 689 dez 13 16:14 example2.txt
-rw-r--r-- 1 user user 348 dez 13 16:14 example.txt
$
```
### Hints
-`chmod` The chmod, or change mode, command allows an administrator to set or modify a file’s permissions. Every UNIX/Linux file has an owner user and an owner group attached to it, and every file has permissions associated with it. The permissions are as follows: read, write, or execute.
This is what the default permissions looks like when you create a file.
```console
$ touch example.txt
$ ls -l example.txt
-rw-rw-r-- 1 user user 348 dez 13 15:31 example.txt
$
```
This is what it looks like if you want to give permissions to read, write and execute to every group.
```console
$ chmod 777 example.txt
$ ls -l example.txt
-rwxrwxrwx 1 user user 348 dez 13 15:31 example.txt
$
```
> 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