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 -ftrack-macro-expansion=2 -fstack-protector-all -Wno-trigraphs -fno-schedule-insns2 -fno-delete-null-pointer-checks -D_FORTIFY_SOURCE=2 -rdynamic -flifetime-dse=1 uname output: Linux i87k 6.8.2-gentoo-x86_64 #1 SMP Fri Apr 5 15:17:56 CEST 2024 x86_64 Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz GenuineIntel GNU/Linux Machine Type: x86_64-pc-linux-gnu
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 $ [ -n "${var:->}" -a -n "something" ] || echo hmm bash: [: syntax error: `-n' unexpected hmm $ var=">" $ [ -n "${var}" -a -n "something" ] || echo hmm bash: [: syntax error: `-n' unexpected hmm etc. But the issue doesn't happen if it's more than one char in the string that's tested for -n or -z, for example : $ [ -n ">>" -a -n "something" ] || echo hmm (no output, or error) Note, the issue is present also in (current latest) FreeBSD's '/bin/sh' and 'bash' and `/bin/[`. But doesn't happen on Gentoo's /usr/bin/[ which is from sys-apps/coreutils-9.5::gentoo $ /usr/bin/[ -n ">" -a -n "something" ] || echo hmm (no output, or error)