[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [sr #111058] Problem transmitting script arguments
From: |
Kerin Millar |
Subject: |
Re: [sr #111058] Problem transmitting script arguments |
Date: |
Mon, 06 May 2024 19:05:51 +0100 |
User-agent: |
Cyrus-JMAP/3.11.0-alpha0-437-gcad818a2a-fm-20240502.001-gcad818a2 |
On Mon, 6 May 2024, at 7:01 PM, Dale R. Worley wrote:
> anonymous <INVALID.NOREPLY@gnu.org> writes:
>> URL:
>> <https://savannah.gnu.org/support/?111058>
>>
>> Summary: Problem transmitting script arguments
>
>> Date: Sat 04 May 2024 10:08:41 AM UTC By: Anonymous
>> I have the following problem with transmitting arguments to a bash script
>> onward to an inside program call.
>>
>> Lets name the inside program 'Z'.
>> An open number of arguments have to be transmitted from the script
>> environment
>> to Z's environment. If an argument aa is given enclosed in double-quotes to
>> the script (because there are blanks within the value) these double-quotes
>> are
>> removed when bash gets hold of it. When I transmit aa by use of $x, $* or $@,
>> the double-quotes are not resurrected by bash, which I think is a tragic
>> mistake because the call of Z obviously suffers a semantic error.
>>
>> So far I could not solve the problem. As this kind of problem cannot be new,
>> is there any recommended way to solve it?
>
> Providing a detailed example would make your requirements clearer.
>
> But if I understand correctly, you want to provide all of the arguments
> that the Bash script receives as arguments to another program, "Z". The
> standard way to do this is:
>
> Z "$@"
>
> Indeed, it appears that $@ was created with special behavior precisely
> to handle this situation. From the manual page:
>
> @ Expands to the positional parameters, starting from one. In
> contexts where word splitting is performed, this expands each
> positional parameter to a separate word; if not within double
> quotes, these words are subject to word splitting. In contexts
> where word splitting is not performed, this expands to a single
> word with each positional parameter separated by a space. When
> the expansion occurs within double quotes, each parameter ex‐
> pands to a separate word. That is, "$@" is equivalent to "$1"
> "$2" ... If the double-quoted expansion occurs within a word,
> the expansion of the first parameter is joined with the begin‐
> ning part of the original word, and the expansion of the last
> parameter is joined with the last part of the original word.
> When there are no positional parameters, "$@" and $@ expand to
> nothing (i.e., they are removed).
>
> Dale
It's likely that your reply will never be seen by the anonymous Savannah issue
filer.
--
Kerin Millar