Tell us what’s happening:
The Course Keeps failing a step, although it should not, because the code does what the step says it should do
It keeps returning:
“Your script should call the suggested function correctly”
Can someone help me out? I’m doing the Bash Scripting workshop
I’m doing it on the virtual machine (vscode)
The current level task:
Now, your function will print one thing if you pass it any argument, and something else if not. In the until loop, add again as an argument to where you call the function.
All the hints of the level:
-
Here’s an example: FUNCTION_NAME argument
-
Your function call should look like this: GET_FORTUNE again
-
Your until loop should look like this:
until [[ $QUESTION =~ \?$ ]]
do
GET_FORTUNE again
done
All of the code in my ./fortune.sh file
#! /bin/bash
# Program to tell a persons fortune
echo -e "\n~~ Fortune Teller ~~\n"
RESPONSES=("Yes" "No" "Maybe" "Outlook good" "Don't count on it" "Ask again later")
echo ${RESPONSES[$N]}
N=$(( RANDOM % 6 ))
GET_FORTUNE() {
if [[ ! $1 ]]
then
echo Ask a yes or no question:
read QUESTION
else
echo Try again. Make sure it ends with a question mark:
fi
}
until [[ $QUESTION =~ \?$ ]]
do
GET_FORTUNE again
done
Yet the level doesn’t pass. I have refreshed, closed the codespace and reopened it. I am almost done with this 220-step workshop. I don’t want to start again
Your code so far
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Safari/605.1.15
Challenge Information:
Build Five Programs - Build Five Programs