help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Taking a slice of an array


From: DJ Mills
Subject: Re: [Help-bash] Taking a slice of an array
Date: Mon, 9 Apr 2012 11:26:11 -0400

On Mon, Apr 9, 2012 at 10:48 AM, Bill Gradwohl <address@hidden> wrote:
>
> I never realized that IFS was * only. Thanks for that nugget.
>


This is discussed in the "Arrays" section, under "PARAMETERS" and
right above "EXPANSION". It's also described for the special
parameters "@" and "*".

>From the "Array"s section:
Any element of an array may be referenced using ${name[subscript]}.
The braces are required to avoid conflicts with pathname expansion.
If subscript is @ or *, the word expands to all members of name.
These subscripts differ only when the word appears within double
quotes.  If the word is double-quoted, ${name[*]} expands to a single
word with the value of each array member separated by the first
character of the IFS special variable, and address@hidden expands each
element of name to a separate word.  When there are no array members,
address@hidden expands to nothing.

I agree that the man page might want to clarify the behavior in the
"Parameter Expansion" section where that operation is described, but
it wouldn't make sense to suddenly change the behavior for that
operation only.  The man page is also not meant to be a tutorial; it's
a reference.  Explaining every little thing like that in each
description would most likely end up making it huge, and very
redundant.



reply via email to

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