On 04.11.2021 09:13, Josef Moellers wrote:
On 04.11.21 06:33, hongy...@gmail.com wrote:
In bash script, both of the following usages are valid:
[ $1 != "frps" -a $1 != "frpc" ]
[[ $1 != "frps" ]] && [[ $1 != "frpc" ]]
Which is preferable?
Depending on the actual requirements (portability anyone?), probably
none of these.
For the first case; POSIX: ">4 arguments: The results are unspecified."
(BTW: Why did you quote the constant literals but not the variables?)
If you don't care about portability and standards use [[...]] .
Many folks forget that we can formulate (even regexp-)comparisons also
with the [standard] 'case' construct
case $1 in (frps|frpc) ;; (*) ... ; esac
The one which is most easily understandable.
...and which shows the least surprises (generally and in your context).
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)