[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: |
Lawrence Velázquez |
Subject: |
Re: Wanted: quoted param expansion that expands to nothing if no params |
Date: |
Wed, 24 Mar 2021 00:41:27 -0400 |
> On Mar 23, 2021, at 11:43 PM, Eli Schwartz <eschwartz@archlinux.org> wrote:
>
> On 3/23/21 11:24 PM, L A Walsh wrote:
>> Too often I end up having to write something like
>> if (($#)); then <func|exec> "$@"
>> else <func|exec> #<func|exec> = function or executable call
>> fi
>>
>> It would be nice to have a expansion that preserves arg boundaries
>> but that expands to nothing when there are 0 parameters
>> (because whatever gets called still sees "" as a parameter)
>>
>> So, example, something like:
>>
>> $~ == "$@" #for 1 or more params
>> $~ == no param when 0 param, # so for the above if/else/endif
>> one could just use 1 line:
>
> It's not clear to me, how you expect this to differ from the existing
> behavior of "$@" or "${arr[@]}" which already expands to <nothing>
> rather than an actual "" parameter.
The original message does recall the behavior of the earliest Bourne
shells [1][2], but that is surely not relevant here, given the use
of ((...)). Right? RIGHT???
[1]: https://www.in-ulm.de/~mascheck/various/bourne_args/
[2]:
https://www.gnu.org/software/autoconf/manual/autoconf-2.70/html_node/Shell-Substitutions.html#index-_0022_0024_0040_0022
vq
Re: Wanted: quoted param expansion that expands to nothing if no params, Dale R. Worley, 2021/03/24