I have a script that has a given number of input variables. I would like to detect if all of the variables have been given and quit otherwise. For example lets say the script has 10 input args but only 6 are given. Then I would like to quit. I tried
arg1=$1
arg2=$2
...
arg10=$10
for i in $(eval echo {$1..$10}); do
echo "$i"
if [[ -z "$i" ]]; then
echo 'wrong number of args'
exit 2
fi
done
The echo inside the loop (echo "$i$"
) prints out but the loop always exits. So I have some basic flaw.