3 ms·
> Alternatively you can use the newer (and highly recommended) bash syntax that is also quote safe Well, mostly: $ a=1; b='*'; c='!'; d='*' $ [[ $a = $b &
by gnubison 6y ago
> Alternatively you can use the newer (and highly recommended) bash syntax that is also quote safe
Well, mostly:
$ a=1; b='*'; c='!'; d='*'
$ [[ $a = $b && $c = $d ]] && echo true
true
$ [[ $a = "$b" && $c = "$d" ]] && echo true
$
From the bash(1) manpage:
> When the == and != operators are used, the string to the right of the operator is considered a pattern and matched according to the rules described below under Pattern Matching, as if the extglob shell option were enabled.
POSIX syntax is more consistent and more portable:
$ [ "$a" = "$b" ] && [ "$c" = "$d" ] && echo true
$