[Cialug] Bash Array Variables

Jeffrey Ollie jeff at ocjtech.us
Thu Aug 11 16:44:15 UTC 2022


IMNSHO, anything that ends up being more than a page full of bash scripting
should be done in Python/Perl/<insert language of choice here>.

On Thu, Aug 11, 2022 at 9:59 AM Todd Walton <tdwalton at gmail.com> wrote:

> $ cat test.sh
> #!/bin/bash
> echo "VARS1: ${VARS1[@]}"
> echo "BARS2: $BARS2"
>
> $ VARS1=(tom jerry)
> $ BARS2=bradybunch
> $ ./test.sh
> VARS1:
> BARS2:
>
> $ export VARS1=(tom jerry)
> $ export BARS2=bradybunch
> $ ./test.sh
> VARS1:
> BARS2: bradybunch
>
> $ # zomg, no VARS1
> $ man bash | awk '/^BUGS/,0'
> BUGS
>        It's too big and too slow.
>
>        There are some subtle differences between bash  and  traditional
>  ver‐
>        sions of sh, mostly because of the POSIX specification.
>
>        Aliases are confusing in some uses.
>
>        Shell builtin commands and functions are not stoppable/restartable.
>
>        Compound  commands  and  command sequences of the form `a ; b ; c'
> are
>        not handled gracefully when process suspension is attempted.   When
>  a
>        process is stopped, the shell immediately executes the next command
> in
>        the sequence.  It suffices to place the sequence of  commands
>  between
>        parentheses  to  force  it  into a subshell, which may be stopped as
> a
>        unit.
>
>        Array variables may not (yet) be exported.
>
>        There may be only one active coprocess at a time.
>
> GNU Bash 5.1                   2020 October 29
>  BASH(1)
>
> $ # "Array variables may not (yet) be exported."
> _______________________________________________
> Cialug mailing list
> Cialug at cialug.org
> https://www.cialug.org/cgi-bin/mailman/listinfo/cialug
>


-- 
Jeff Ollie
The majestik møøse is one of the mäni interesting furry animals in Sweden.


More information about the Cialug mailing list