bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Add syntax to expand arrays with indicies.


From: Mario V Nigrovic
Subject: Add syntax to expand arrays with indicies.
Date: Fri, 14 Mar 2003 19:38:49 -0700 (MST)

Configuration Information [Automatically generated, do not change]:
Machine: sparc
OS: solaris2.8
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='sparc' 
-DCONF_OSTYPE='solaris2.8' -DCONF_MACHTYPE='sparc-sun-solaris2.8' 
-DCONF_VENDOR='sun' -DSHELL -DHAVE_CONFIG_H  -D_LARGEFILE_SOURCE 
-D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -I.  -I/media/gnu/bash-2.05 
-I/media/gnu/bash-2.05/include -I/media/gnu/bash-2.05/lib 
-I/tools/GNU/003/SunOS_5.8/include -g -O2
uname output: SunOS jaguar 5.8 Generic_108528-13 sun4u sparc SUNW,Ultra-60
Machine Type: sparc-sun-solaris2.8

Bash Version: 2.05
Patch Level: 0
Release Status: release

Description:
        It would be really nice to be able to print arrays, with indices.

Repeat-By:
        I propose a syntax, say ${=array[*]} which would print out the
        array in an array-assignable fashion.

        $ fred=(a b [4]=c)
        $ echo ${fred[*]}
        a b c
        $ echo ${#fred[*]}
        3
        $ echo ${fred[4]}
        c

        so far, so good.  But:

        betty=(${fred[@]})
        $ echo ${#betty[*]}
        3
        $ echo ${betty[0]}
        a
        $ echo ${betty[1]}
        b
        $ echo ${betty[2]}
        c
        $ echo ${betty[4]}


        Wouldn't it be useful to have a syntax like

        $ echo ${=fred[*]}
        [0]=a [1]=b [4]=c

        so that you could

        $ betty=( ${=fred[*]} )

        and have

        $ echo ${betty[4]}
        c

        What do you think?

        -- Mario




reply via email to

[Prev in Thread] Current Thread [Next in Thread]