[Top][All Lists]

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

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

From: Alejandro Colomar
Subject: Re: [bash 4] 'test -v 1' is never true
Date: Sun, 27 Nov 2022 14:00:35 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.0

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.





Attachment: OpenPGP_signature
Description: OpenPGP digital signature

reply via email to

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