[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Expansion of ${!x*} and ${!x@}
From: |
Linda Walsh |
Subject: |
Expansion of ${!x*} and ${!x@} |
Date: |
Tue, 07 Nov 2006 14:25:19 -0800 |
User-agent: |
Thunderbird 1.5.0.7 (Windows/20060909) |
The manpages for "my" bash's (3.1.11 on Linux and 3.1.17 on cygwin/i686),
under Parameter Expansion, say:
${!prefix*}
${!prefix@}
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 ' @ ' = ${!U@} ; \ # (line 2 - @ unquoted)
echo '"*"' = "${!U*}" ; \ # (line 3 - * quoted)
echo '"@"' = "${!U@}" # (line 4 - @ quoted)
---
output:
* = UID USER # (line 1)
@ = UID USER # (line 2)
"*" = UID<USER # (line 3)
"@" = UID USER # (line 4)
---
QUESTIONS continued...
- If the two forms are supposed to be identical, why aren't lines
3 & 4 the same?
- Why do the quotes in line 3 make for different output than in line
Why aren't the 4 lines identical? I see the IFS, "<" in line 3, but
not in lines 1,2&4. Why isn't it in all 4 lines and, also, even
the double quotes make a difference when expanding variables, why
aren't lines 3&4 the same?
- Expansion of ${!x*} and ${!x@},
Linda Walsh <=