shelllings

a practical way to learn shell
git clone https://git.davidvoz.net/shelllings.git
index
logs
tree
license

04_navigation.sh
1#!/bin/sh
2
3set -eu
4RED="\033[31m"
5GREEN="\033[32m"
6RESET="\033[0m"
7
8cleanup() {
9 [ -d "blueberry" ] && rm -rf blueberry
10}
11trap cleanup EXIT
12
13failed() {
14 printf "${RED}Failed${RESET}\n"
15 exit 1
16}
17
18mkdir -p blueberry/strawberry/grape/lemon
19mkdir -p blueberry/strawberry/cherry/
20
21touch blueberry/strawberry/grape/lemon/.you_found_me.txt
22echo "The password is grannyApples" > blueberry/strawberry/grape/lemon/.you_found_me.txt
23
24echo "Find the grape folder, the file with the password might"
25echo "be hard to find, but it is there."
26
27if [ "$(sh exercises/04_navigation.sh)" = "grannyApples" ]; then
28 printf "${GREEN}Passed${RESET}\n"
29else
30 failed
31fi