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 "08_cat" ] && rm 08_cat |
| 10 | } |
| 11 | trap cleanup EXIT |
| 12 | |
| 13 | failed() { |
| 14 | printf "${RED}Failed${RESET}\n" |
| 15 | exit 1 |
| 16 | } |
| 17 | |
| 18 | output=$(sh exercises/08_cat.sh) |
| 19 | answer=$(tail -n 50 LICENSE | wc -w) |
| 20 | |
| 21 | [ $(wc -w < 08_cat) -eq $answer ] || failed |
| 22 | |
| 23 | printf "${GREEN}Passed${RESET}\n" |