The commands, such as ./demo.sh rotate, ./demo sh stop, and terms such as “argument” are not taught before moving on to work on the scripts in 3.2.1. What are the usage of those commands? Are there other Bash commands that I need to learn before working on the scripts?
Overall the materials are easy to follow until Section 3.2.1 where I start getting lost. I feel that I may have missed something after Exercise 3.3. but before Section 3.2.1. Can you help?
the “arguments” are defined inside the demo.sh file itself. You, as the creator of a bash script, is the one who defines the arguments it accepts.
Let’s for example see the script below (let’s put the content below in a file named learning.sh):
#! /bin/bash
argument=$1
if [ "${argument}" == "marksix11" ]; then
echo "Congratlations, you passed the right argument."
else
echo "[Error]: Provided argument '${argument}' is not the expected one."
fi
If you just call it without arguments with ./learning.sh, it will print:
[Error]: Provided argument ‘’ is not the expected one.
If you pass “rotate” as argument, ./learning.sh rotate, it will print:
[Error]: Provided argument ‘rotate’ is not the expected one.
If you then max “marksix11” as argument, ./learning.sh marksix11, it will say you passed the correct argument:
Congratlations, you passed the right argument.
In this example, the script was expecting marksix11 as argument. It could be anything.
Please let me know if you still have some questions, but I aggree that we have to improve this demo.sh script.