Expansion of ${!x*} and [EMAIL PROTECTED]

2006-11-07 Thread Linda Walsh

The manpages for "my" bash's (3.1.11 on Linux and 3.1.17 on cygwin/i686),
under Parameter Expansion, say:


${!prefix*}
[EMAIL PROTECTED]
   Expands to the names of variables whose names begin with prefix,
   separated by the first character of the IFS special variable.

---
From this, I'd expect both forms to have the same output.
Is this what is intended and what I should expect?

For test purposes, I set:
  IFS="<" OFS=">"   # (also set "Output" FS to see if it is used
#  in the output of 'echo')
---
I used 4 tests, all with prefix=U, 1st pair unquoted, 2nd pair quoted.
input:
  echo ' * ' =  ${!U*}; \ # (line 1 - * unquoted)
  echo ' @ ' =  [EMAIL PROTECTED]; \ # (line 2 - @ unquoted)
  echo '"*"' = "${!U*}"   ; \ # (line 3 - * quoted)
  echo '"@"' = "[EMAIL PROTECTED]"   # (line 4 - @ quoted)
---
output:
   *  = UID USER  # (line 1)
   @  = UID USER  # (line 2)
  "*" = UIDhttp://lists.gnu.org/mailman/listinfo/bug-bash


Re: Expansion of ${!x*} and [EMAIL PROTECTED]

2006-11-07 Thread Matthew Woehlke

Linda Walsh wrote:

The manpages for "my" bash's (3.1.11 on Linux and 3.1.17 on cygwin/i686),
under Parameter Expansion, say:


${!prefix*}
[EMAIL PROTECTED]
   Expands to the names of variables whose names begin with prefix,
   separated by the first character of the IFS special variable.

[snip]
output:
   *  = UID USER  # (line 1)
   @  = UID USER  # (line 2)
  "*" = UID

I would assume that this works the same as other uses of * and @; if you 
quote them, * expands to a single Word, while @ expands to a Word for 
each logical element (so that any spaces in each element are preserved). 
Similar to how if your argv is 'foo' 'bar none', "$*" gives the single 
Word 'foo bar none' and "$@" gives { 'foo', 'bar none' }.


IOW this looks like the doc maybe should mention this and fails to do so.

--
Matthew
"Try to bring it back in one piece this time." -- Q (MI6)



___
Bug-bash mailing list
Bug-bash@gnu.org
http://lists.gnu.org/mailman/listinfo/bug-bash