bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bash 4] 'test -v 1' is never true


From: Martin D Kealey
Subject: Re: [bash 4] 'test -v 1' is never true
Date: Mon, 28 Nov 2022 02:53:40 +1000

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.manpages@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/>
>


reply via email to

[Prev in Thread] Current Thread [Next in Thread]