Re: syntax error with lone > or < as string in [ ] tests with -a or -o operators

2024-04-15 Thread Andreas Schwab
On Apr 15 2024, Greg Wooledge wrote: > And that's a bug. That code is wrong, and it should be written this way > instead: > > [ -z "$var1" ] && [ -z "$var2" ] && continue Or just [ -z "$var1$var2" ] && continue -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5

Re: syntax error with lone > or < as string in [ ] tests with -a or -o operators

2024-04-15 Thread Greg Wooledge
On Mon, Apr 15, 2024 at 08:13:23PM +0200, Emanuel Attila Czirai wrote: > On Mon, Apr 15, 2024 at 7:56 PM Greg Wooledge wrote: > > Sounds like you've found a nontrivial bug in FreeBSD (in the adduser > > script, not in sh). I hope this gets reported and fixed, and in any case, > > good work and

Re: syntax error with lone > or < as string in [ ] tests with -a or -o operators

2024-04-15 Thread Emanuel Attila Czirai
On Mon, Apr 15, 2024 at 7:56 PM Greg Wooledge wrote: > On Mon, Apr 15, 2024 at 07:04:23PM +0200, Emanuel Attila Czirai wrote: > > 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

Re: syntax error with lone > or < as string in [ ] tests with -a or -o operators

2024-04-15 Thread Greg Wooledge
On Mon, Apr 15, 2024 at 07:04:23PM +0200, Emanuel Attila Czirai wrote: > 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

Re: syntax error with lone > or < as string in [ ] tests with -a or -o operators

2024-04-15 Thread Emanuel Attila Czirai
On Mon, Apr 15, 2024, 15:08 Chet Ramey 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

Re: syntax error with lone > or < as string in [ ] tests with -a or -o operators

2024-04-15 Thread Chet Ramey
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: $

Re: syntax error with lone > or < as string in [ ] tests with -a or -o operators

2024-04-14 Thread Greg Wooledge
On Sun, Apr 14, 2024 at 11:16:27AM +0200, Emanuel Attila Czirai wrote: > $ [ -n ">" -a -n "something" ] || echo hmm > bash: [: syntax error: `-n' unexpected > hmm Don't do this. You're in the land of unspecified behavior here. Use multiple test or [ commands instead, or use bash's [[ command.

syntax error with lone > or < as string in [ ] tests with -a or -o operators

2024-04-14 Thread Emanuel Attila Czirai
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: x86_64-pc-linux-gnu-gcc Compilation CFLAGS: -march=skylake -mtune=skylake -mprefer-vector-width=128 -O2 -pipe -frecord-gcc-switches -ggdb -fvar-tracking-assignments -fno-omit-frame-pointer