[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: |
Sun, 20 Oct 2019 08:08:32 -0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 |
On 10/20/19 7:29 AM, Peng Yu wrote:
>> If that is too slow compared
>> to using an array, then I must assume that you have so much data that
>> doing whatever you're doing in another language would be preferable.
>
> Stdin can have an unlimited amount of data. This approach time
> complexity is not linear with respect to the input. That is what I
> mean by too slow.
Reading lines one at a time and mutating "${a[@]}" repeatedly is also
not very fast when dealing with unlimited data, maybe you'd prefer to
use `mapfile -t a` which also avoids the need to set IFS=
But I figure any script dealing with unlimited number of args will also
have to... do something with an unlimited number of args, so that will
be pretty slow too.
>> Also, is the use of an additional array variable not wanted due to
>> purely aesthetic reasons?
>
> Yes. The name of the variable "a" is nonessential. It is mentioned
> twice. From the succinct perspective of the language, if it can be
> avoided, it would be best.
It would be even nicer if we could avoid other non-succinct things, like
while
IFS=
read
do
done
set
All of which could be gotten rid of if bash just knew what you wanted. I
demand a new feature for bash which reads my mind and does what I want
without requiring me to program it first.
...
Anyway, the Environmental Protection Agency recommends using `unset a`
when done. Does this suffice?
--
Eli Schwartz
Arch Linux Bug Wrangler and Trusted User
signature.asc
Description: OpenPGP digital signature
Re: [Help-bash] append to $@ one by one, Jesse Hathaway, 2019/10/21