Overview:
I am trying to code an error for a function that requires multiple arguments.
example:
myfunction arg1 arg2 arg3 arg4
If any of these arguments are null I want to trow the user a syntax error.
Attempts:
Without writing the individual arguments I tried:
# Error Checking
for i in "{1.4}"
do
# Check for null values of Bash variables:
[[ -z $"$i" ]] && {
printf "Syntax Error: Missing Operator see:\nmyfunction --help\n"
exit
}
done
-and-
# Error Checking
for i in ${1..4}
do
# Check for null values of Bash variables:
[[ -z $i ]] && {
printf "Syntax Error: Missing Operator see:\nmyfunction --help\n"
exit
}
done
Attempted syntax check:
Question:
Is what I am trying to do possible with a for loop?
Any help would be much appreciated.
Thanks in advance!
Edit:
Also tried the following before I started messing with quotes and dollar signs:
# Error Checking
for i in {1..4}
do
[[ -z $"$i" ]] && {
printf "Syntax Error: Missing Operator see:\nansi-color --help\n"
exit
}
done