shelllings |
git clone https://git.davidvoz.net/shelllings.git
|
| 1 | #!/bin/sh |
| 2 | |
| 3 | set -eu |
| 4 | RED="\033[31m" |
| 5 | GREEN="\033[32m" |
| 6 | RESET="\033[0m" |
| 7 | |
| 8 | cleanup(){ |
| 9 | [ -f "09_file" ] && rm 09_file |
| 10 | } |
| 11 | trap cleanup EXIT |
| 12 | |
| 13 | failed() { |
| 14 | printf "${RED}Failed${RESET}\n" |
| 15 | exit 1 |
| 16 | } |
| 17 | |
| 18 | sh exercises/09_direction.sh |
| 19 | output=$(wc -l < 09_file) |
| 20 | answer=$(cat LICENSE exercises/* | wc -l) |
| 21 | |
| 22 | [ $output -eq $answer ] || failed |
| 23 | |
| 24 | printf "${GREEN}Passed${RESET}\n" |