bug-bash
[Top][All Lists]
Advanced

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

Documentation of expansion of "prefix address@hidden suffix"


From: Enrique Perez-Terron
Subject: Documentation of expansion of "prefix address@hidden suffix"
Date: Wed, 25 Aug 2004 21:55:23 +0200

Given the code

   $ myarray=( arg1 arg2 arg3 )
   $ for arg in "prefix address@hidden suffix"
   > do 
   >   echo "'$arg'"
   > done

The documentation appears to suggest one should expect this:

   'prefix '
   'arg1'
   'arg2'
   'arg3'
   ' suffix'

rather than this (which is implemented):

   'prefix arg1'
   'arg2'
   'arg3 suffix'

At least, that is how I read "each element .. a separate word".

Does any standard specify what is the right thing to do? 

If not, is there any reason to prefer one over the other?

Suggested rephrasing:

   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 sep-
-  arate  word.
+  special variable, and address@hidden expands each element of name except the
+  first and last, to a separate word, while the first and last elements 
+  become contiguous with any preceding and following parts respectively, 
+  of the word.

or

+  special variable, and address@hidden substitutes the array members and splits
+  the resulting word where the first character of the IFS special variable 
+  would have been inserted had the index been specified as "*". Thus, the
+  word "prefix address@hidden suffix" expands to as many words as there are 
members
+  of the array if there is at least one member, or to one word if there are no 
+  members but the word, as here, has other characters.

It seems like the other behavior is easier to describe. <taunt>Could it be that
it is more intuitive?</taunt>

Regards,
Enrique





reply via email to

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