FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian User

 
 
LinkBack Thread Tools
 
Old 04-24-2012, 02:36 AM
"Dan B."
 
Default Bash script problem

I wrote:

...

FILES_LIST=( "${FILES_LIST[@]}" "${NEW_FILE}" )



You can also write:

FILE_LIST[${#FILE_LIST[@]}]="${NEW_FILE}"


Daniel


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

Archive: 4F961197.4010304@kempt.net">http://lists.debian.org/4F961197.4010304@kempt.net
 
Old 04-24-2012, 08:03 AM
Chris Davies
 
Default Bash script problem

Cam Hutchison <camh@xdna.net> wrote:
> BK_LIST=()

> Append to the array with +=
> BK_LIST+="${PARAM}"

This += syntax appears not to work with my version of bash
("4.1.5(1)-release" from package bash 4.1-3). Instead I have
to do this:

BK_LIST+=("${PARAM}")

Was yours a typo, or is it something that now works in yet newer
versions of the shell?

Curious,
Chris


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 9c3i69xhhv.ln2@news.roaima.co.uk">http://lists.debian.org/9c3i69xhhv.ln2@news.roaima.co.uk
 
Old 04-25-2012, 06:20 AM
Cam Hutchison
 
Default Bash script problem

Chris Davies <chris-usenet@roaima.co.uk> writes:

>Cam Hutchison <camh@xdna.net> wrote:
>> BK_LIST=()

>> Append to the array with +=
>> BK_LIST+="${PARAM}"

>This += syntax appears not to work with my version of bash
>("4.1.5(1)-release" from package bash 4.1-3). Instead I have
>to do this:

> BK_LIST+=("${PARAM}")

>Was yours a typo, or is it something that now works in yet newer
>versions of the shell?

Sigh. Sorry, it was a typo. That explains why it did not work for the OP.
I though that was strange, since I've successfully used arrays to maintain
argument vectors with arguments containing spaces. I was so sure it worked
that I focussed on testing the wrong part.


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 1039.4f979796.5295d@xionine.xdna.net">http://lists.debian.org/1039.4f979796.5295d@xionine.xdna.net
 
Old 04-25-2012, 08:05 AM
Chris Davies
 
Default Bash script problem

Cam Hutchison <camh@xdna.net> wrote:
> Sigh. Sorry, it was a typo. That explains why it did not work for the OP.

Phew!

These array things are new to me in a shell context - I've used
associative and indexed arrays for years in awk and perl, though - and
after your example didn't work I went digging through the man page.

I missed it the first time I read the paragraph, but then twigged the
explicit use of the word "compound" in the relevant sentence: "When +=
is applied to an array variable using compound assignment (see Arrays
below) ... new values are appended to the array ...". Digging further
I found that "compound" referred to a list assignment such as X=($Y $Z).

Regards,
Chris


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: ornk69xaek.ln2@news.roaima.co.uk">http://lists.debian.org/ornk69xaek.ln2@news.roaima.co.uk
 

Thread Tools




All times are GMT. The time now is 12:11 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org