bug-bash
[Top][All Lists]
Advanced

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

Re: Wanted: quoted param expansion that expands to nothing if no params


From: Eli Schwartz
Subject: Re: Wanted: quoted param expansion that expands to nothing if no params
Date: Wed, 24 Mar 2021 18:16:19 -0400

On 3/24/21 3:49 PM, Ilkka Virta wrote:
> On Wed, Mar 24, 2021 at 9:38 PM L A Walsh <bash@tlinx.org> wrote:
> 
>>     Hmmm...Now that I try to show an example, I'm not getting
>> the same results.  Grrr.  Darn Heizenbugs.
>>
> 
> Just remember that if you test with printf, it always prints at least once,
> which makes it look exactly as if it got an empty string argument, even if
> there are none:
> 
> $ set --
> $ printf ":%s:\n" "$@"
> ::
> $ set -- ; printf ":%s:\n" x "$@"
> :x:


Testing with set -x is preferred.

$ set -x --; printf ":%s:\n" "$@"
+ printf ':%s:\n'
::
$ set -x --; printf ":%s:\n" x "$@"
+ set -x --
+ printf ':%s:\n' x
:x:

-- 
Eli Schwartz
Arch Linux Bug Wrangler and Trusted User

Attachment: OpenPGP_signature
Description: OpenPGP digital signature


reply via email to

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