On 04.11.2021 12:21,
hongy...@gmail.com wrote:
> On Thursday, November 4, 2021 at 5:40:14 PM UTC+8, Janis Papanagnou wrote:
>> 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?)
>
> Negligence or bad habit of mine :-(
>
>> 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
>
> Which type of regexp is supported here?
(The same that are also supported in the non-standard 'if [[ ... ]]'