Trying to set rules if a certain variable is put into place, can someone identify wtf I’m missing here?
test.sh:
#!/bin/bash
args=($@)
if [ "$@" = "--cron" ]; then
echo "WORKS!";
else echo "FAILS"
fi
output of ./test.sh:
./test.sh: line 3: [: =: unary operator expected
FAILS
However, when I run ./test.sh --cron, it works, and WORKS is output.
In this case, I believe
"$@"is too well quoted.Try comparing against
"$1", or use: