[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: arrays
From:       David Henderson <dhenderson () digital-pipe ! com>
Date:       2016-08-04 21:03:05
Message-ID: CAF-YAQxEce1tA=7Lc44SHSEMiCzZWBTVxfjC9jsSH7amkVOuMg () mail ! gmail ! com
[Download RAW message or body]

Thanks for the continued replies Jody :)

I would love to, but I'm not very effective at that low level of
programming.  More of a shell and web-based programmer...

Rob Landley, do you have any plans on implementing arrays in the toolbox shell?

Thanks,
Dave


On 8/4/16, Jody Lee Bruchon <jody@jodybruchon.com> wrote:
> I don't know if there is interest in adding arrays to BusyBox ash. I would
> imagine that if it was removable at compile time and was Bash-compatible
> that it would certainly be accepted as a patch for BusyBox. There are
> already plenty of Bashisms supported by ash as implemented in BusyBox, and
> arrays certainly are super useful. Someone would have to code it in though,
> and that's the hard part. ;-)
>
> On August 4, 2016 2:41:25 PM EDT, David Henderson
> <dhenderson@digital-pipe.com> wrote:
>>Thanks for the response Jody!  I understand that BB is POSIX
>>compliant, but didn't realize that arrays are not part of POSIX.  Is
>>there any chance or interest in adding slightly more than that
>>standard in BB?  The reason I ask is that, based on the response below
>>(and most likely any other responses too), the options are to bloat
>>(and create less readability) the shell scripts with insecure eval
>>statements and tons of loops to create and process individual
>>variables, or to bloat the OS by adding additional software (which
>>could also be a security risk due to the bugs in that additional
>>software).  Neither of those seems like a good choice.  Arrays are
>>commonly used today, perhaps not in the 70's :), but today they are.
>>
>>Dave
>>
>>
>>On 8/4/16, Jody Lee Bruchon <jody@jodybruchon.com> wrote:
>>> ash (the BusyBox shell) is POSIX compliant but is not Bash
>>compatible. To
>>> use arrays, you have to do some trickery with the eval command to
>>simulate
>>> them with normal variables. It is not nearly as convenient as Bash
>>arrays
>>> nor as easy to read, but it is workable. Essentially you maintain a
>>counter
>>> yourself and when you need to refer to an array variable you do
>>something
>>> like
>>>
>>> eval DRIVE$CNT=123
>>> eval echo DRIVE$CNT
>>>
>>> Which uses the value in CNT as part of the variable name being
>>referenced.
>>>
>>> I haven't done this in a while so I may have something wrong, but
>>that's the
>>> general idea. The alternative is of course to install Bash and not
>>need to
>>> do this in the first place.
>>>
>>> On August 4, 2016 9:57:15 AM EDT, David Henderson
>>> <dhenderson@digital-pipe.com> wrote:
>>>>So I'm trying to process the attached storage devices and their
>>>>partitions (which get stored in arrays since the data is referenced
>>>>multiple times).  Since I don't know what any one particular user
>>will
>>>>have, I can't create individual variables for this and use arrays.
>>>>I'm still looking for help with this.
>>>>
>>>>Thanks,
>>>>Dave
>>>>
>>>>
>>>>On 8/2/16, David Henderson <dhenderson@digital-pipe.com> wrote:
>>>>> Good morning all!  I have a script that uses arrays, but I can't
>>seem
>>>>> to figure out what's going on with /bin/sh in handling them.  Is
>>>>there
>>>>> a specific way to initialize them or use them with busybox?
>>>>>
>>>>> Thanks,
>>>>> Dave
>>>>>
>>>>_______________________________________________
>>>>busybox mailing list
>>>>busybox@busybox.net
>>>>http://lists.busybox.net/mailman/listinfo/busybox
>>>
>>> --
>>> Sent from my Android phone with K-9 Mail. Please excuse my brevity.
>>>
>
> --
> Sent from my Android phone with K-9 Mail. Please excuse my brevity.
>
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic