On Mon, Apr 15, 2024, 15:08 Chet Ramey <chet.ra...@case.edu> wrote: > On 4/14/24 5:16 AM, Emanuel Attila Czirai wrote: > > > Bash Version: 5.2 > > Patch Level: 26 > > Release Status: release > > > > Description: > > the [ test with -n or -z on a string that's only the angle bracket > char > > followed by -a or -o operators, fails like: > > bash: [: syntax error: `-n' unexpected > > > > Repeat-By: > > > > $ [ -n ">" -a -n "something" ] || echo hmm > > bash: [: syntax error: `-n' unexpected > > hmm > > I think the part your analysis is missing is that `<' and `>' are binary > operators, so this really is an ambiguous expression. > In my superficial report, I definitely didn't think of that. I even forgot to mention that it works when escaped like "\>"
I've encountered it in the "adduser" FreeBSD sh script that runs as root, while trying to set a one char password like ">", so I thought I'd mention it here as well in case it might be helpful since I saw it happens in bash as well. Thanks, everyone. Have a great day&all! > > > POSIX test specifies what happens when there are four or fewer arguments > (and the upcoming issue 8 will remove -a/-o/(/) altogether); when you > have more than four you're dealing with historical algorithms. Historical > parsing gave the string comparison binary operators higher precedence than > the unary operators. > > -- > ``The lyf so short, the craft so long to lerne.'' - Chaucer > ``Ars longa, vita brevis'' - Hippocrates > Chet Ramey, UTech, CWRU c...@case.edu http://tiswww.cwru.edu/~chet/ > >