[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] append to $@ one by one
From: |
Eli Schwartz |
Subject: |
Re: [Help-bash] append to $@ one by one |
Date: |
Sat, 19 Oct 2019 21:26:54 -0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 |
On 10/19/19 9:15 PM, Daniel Mills wrote:
> Why not just append all at the same time?
>
> while IFS= read -r x; do
> a+=("$x")
> done
> # some other logic that sets x and y
> set -- "$a[@]}" "$x" "$y"
>
> Alternatively, just append to the array and then do your set. There's no
> method to append to the positional parameters, it's either setting them all
> at once or not at all.
The questioner explicitly called out this method, said "I'm currently
doing it that way", and said "I want something better, which I define as
not requiring the definition of an array other than @"
So your answer could be rewritten as "No, you are currently using the
only valid method. bash doesn't have functionality to append to the
positional parameters. Carry on as you are now."
Aside: your "alternatively" doesn't seem to be much of an alternative,
as it describes the first thing you suggested rather than being an
alternative?
--
Eli Schwartz
Arch Linux Bug Wrangler and Trusted User
signature.asc
Description: OpenPGP digital signature
- [Help-bash] append to $@ one by one, Peng Yu, 2019/10/19
- Re: [Help-bash] append to $@ one by one, Daniel Mills, 2019/10/19
- Re: [Help-bash] append to $@ one by one,
Eli Schwartz <=
- Re: [Help-bash] append to $@ one by one, Andreas Kusalananda Kähäri, 2019/10/20
- Re: [Help-bash] append to $@ one by one, Peng Yu, 2019/10/20
- Re: [Help-bash] append to $@ one by one, Eli Schwartz, 2019/10/20
- Re: [Help-bash] append to $@ one by one, Gerard E. Seibert, 2019/10/20
- Re: [Help-bash] append to $@ one by one, Peng Yu, 2019/10/20
- Re: [Help-bash] append to $@ one by one, Eduardo Bustamante, 2019/10/20
- Re: [Help-bash] append to $@ one by one, Peng Yu, 2019/10/20
- Re: [Help-bash] append to $@ one by one, Andreas Kusalananda Kähäri, 2019/10/21
Re: [Help-bash] append to $@ one by one, Jesse Hathaway, 2019/10/21