Can anybody tell me what is wrong with this syntax:
if [ "$1" == "postfix" || "$1" == "all" ]; then
echo test
fi
Use either
if [ "$1" = "postfix" ] || [ "$1" = "all" ]; then
or
if [ "$1" = "postfix" -o "$1" = "all" ]; then
|| combines two commands (and the [ is a command). Within the [ ... ] the operator -o is used for or.
Another way to use || is to use it inside [[ instead of [.
In any way, the correct operator for equality is = inside [ ... ] as it is the POSIX standard (according to man bash). == is supported, though.
If you want to do this, use [[ test form :
if [[ $1 == "postfix" || $1 == "all" ]; then
[[ is a bash keyword similar to (but more powerful than) the [ command. See http://mywiki.wooledge.org/BashFAQ/031 and http://mywiki.wooledge.org/BashGuide/TestsAndConditionals Unless you're writing for POSIX sh, we recommend [[
or
if [ "$1" == "postfix" ] || [ "$1" == "all" ]; then
[ a == b ] || [ c == d ]or[ a == b -o c == d ]. Or[[ ... ]]instead.