[comp.unix.shell] Need help on Bash syntax

brad@SSD.CSD.HARRIS.COM (Brad Appleton) (09/06/90)

Ive been trying to get an answer to this for weeks. I hope someone in this
newsgroup will come through for me!!!!

I need to know everything about bash arrays (assuming they exist).
how does one do the following in bash (if possible):

1) set an array
2) unset an array
3) index an array (get a particular element)
4) modify an array element
5) index a subset of elements (like $argv[3-5] in csh)
6) modify a subset of elements

are there any other subtleties (like "set -A" versus "set +A" in ksh)?
Im getting desperate for this info -- please give me as much info as you 
can on bash arrays.

Also, in bash, what characters need to be escaped inside of double
quotes (including "\", '$' and '`' etc ...) in order to interpreted
literally by the shell (I need an exhaustive list).

I have somewhat of a time limit and I cant wait long enough for the 
documentation to arrive (and no one here has it).

Any and all help is much appreciated!!!!!!

______________________ "And miles to go before I sleep." ______________________
 Brad Appleton        brad@travis.ssd.csd.harris.com   Harris Computer Systems
                          ...!uunet!hcx1!brad          Fort Lauderdale, FL USA
~~~~~~~~~~~~~~~~~~~~ Disclaimer: I said it, not my company! ~~~~~~~~~~~~~~~~~~~

chet@cwns1.CWRU.EDU (Chet Ramey) (09/06/90)

Brad Appleton asks:

>Im getting desperate for this info -- please give me as much info as you 
>can on bash arrays.

OK.  Bash does not have arrays.  Yet.  Maybe later.

>Also, in bash, what characters need to be escaped inside of double
>quotes (including "\", '$' and '`' etc ...) in order to interpreted
>literally by the shell (I need an exhaustive list).

Inside double quotes, all characters retain their literal meanings, with
the exception of $, `, and \.  $ and ` retain their special meaning.  The
backslash is special only when followed by one of the following characters:
$, `, ", \, or <newline>.

Here are some examples:

cwns1$ recho "\\"
argv[1] = "\"
cwns1$ recho "\b"
argv[1] = "\b"
cwns1$ recho "$PS1"
argv[1] = "cwns1$ "
cwns1$ recho "`echo hi`"
argv[1] = "hi"
cwns1$ recho "\$"
argv[1] = "$"
cwns1$ recho "\""
argv[1] = """
cwns1$ recho "\`"
argv[1] = "`"

I have fixed a lot of bugs in bash quoting and substitution, which should
all be in the next version.

>I have somewhat of a time limit and I cant wait long enough for the 
>documentation to arrive (and no one here has it).

FTP to cwns1.ins.cwru.edu (129.22.8.43) for my bash man page.  It's
in ~ftp/pub/bash.1.  The file ~ftp/pub/CWRU-differences lists the
items that differ between what is described in the manual (which is
for the version of bash in use at CWRU).  Most of that stuff should
make it into version 1.06.

Chet
-- 
Chet Ramey				``Levi Stubbs' tears run down
Network Services Group			  his face...''
Case Western Reserve University	
chet@ins.CWRU.Edu