The expansion `$[var+replacement}` was part of the Bourne shell when I used it in 1985 (before POSIX was first published), whereas `test A -gt B` is rather newer, and `test -v` is only a Bash extension (and similarly wasn't added until later).
The man and info pages have retained the rather terse descriptions of those oldest expansions, and they are buried in the sheer volume of the current documentation. On Sun, 27 Nov 2022 at 23:00, Alejandro Colomar <alx.manpa...@gmail.com> wrote: > Hi Alexey, > > On 11/27/22 12:41, Alexey wrote: > > On 2022-11-26 21:45, Alejandro Colomar wrote: > >> That was my gut; thanks! I'll workaround with $#. > > > > I could suggest you to use for clarity another construction: > > [[ ${1+isset} ]] || echo "not set" > > > > Here "isset" is just for readability. You could place any other string > literal > > there. > > I actually find that very confusing. What feature is it using? I > couldn't find > it with `info bash | less` then `/\+`. > > test $# -ge 1 > > has the benefit that it's just a sed(1) away from my old > > test -v 1 > > And it only needs the following to be understood: > > man test | grep -A1 ' -ge ' > man sh | grep ' # ' > > The old version (test -v 1) required: > > help test | grep ' -v ' > man sh | sed -n '/^ Positional/,/^$/p' > > Both are easy to find. > > > > > Regards, > > Alexey. > > Cheers, > > Alex > > -- > <http://www.alejandro-colomar.es/> >