On Sun, Mar 14, 2021 at 7:32 PM Rong Chen <[email protected]> wrote:
>
> It can be reproduced with '-a' option in dash:
Oh, ok. That kind of explains it.
'dash' is trash. Please somebody make a bug report.
> $ a="!"
> $ [ "$a" = ".size" ]
> $ [ "$a" = ".size" -a "$b" = ".LPBX0," ]
> sh: 2: [: =: unexpected operator
This is 100% a dash bug. There is no question what-so-ever about it.
This is not some kind of "POSIX is ambiguous", or "the handling of
'-a' is complicated".
It's simply just that dash is buggy.
> While dash supports most uses of the -a and -o options, they have
> very confusing semantics even in bash and are best avoided.
No, they have perfectly sane semantics in bash, and in POSIX.
See
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html
and there is absolutely zero question that bash does this correctly,
and dash does not.
But yes, it seems to be easy to work around, but still - could some
Ubuntu person please open a bug report on dash?
Linus