What would happen if no parameters had been passed to the script
Here is how one can verify that there is at least one parameter in the list:
#!/bin/sh
if test $# -eq 0
then
echo there must be at least one parameter on the command line
else
until test $# -eq 0
do
echo parameter $1
shift
done
fi
exit 0
Another way to write this same program is
#!/bin/sh
if test $# -eq 0
then
echo there must be at least one parameter on the command line
exit 1
fi
until test $# -eq 0
do
echo parameter $1
shift
done
exit 0
Note that the format of the if statement is
if comparisonThe else is optional, or if followed by another if, could be replaced by elif. The statement is ended by fi (``if" spelled backwards).
then
. . .
else
. . .
fi