mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Fix ${!foo@} and ${!foo*} to include 'foo' itself in search
These expansions are supposed to yield all variable names beginning with the indicated prefix. This should include the variable name that is identical to the prefix (as 'prefix' begins with 'prefix'). This bugfix is backported from the abandoned ksh 93v- beta, so AT&T intended this change. It also makes ksh work like bash in this. src/cmd/ksh93/sh/macro.c: varsub(): M_NAMESCAN: - Check if the prefix itself exists. If so, start with that. src/cmd/ksh93/tests/variables.sh: - Add tests for these expansions. src/cmd/ksh93/sh.1: - Fix the incomplete documentation of these expansions. src/cmd/ksh93/COMPATIBILITY: - Note the change as it's potentially incompatible in corner cases. Resolves: https://github.com/ksh93/ksh/issues/183
This commit is contained in:
parent
e58637752a
commit
4a8072e826
6 changed files with 32 additions and 3 deletions
|
@ -1247,5 +1247,16 @@ exp=42.0000000000
|
|||
[[ $got == "$exp" ]] || err_exit "\${a:=b}: expansion not working for float type (expected '$exp', got '$got')"
|
||||
[[ $a == "$exp" ]] || err_exit "\${a:=b}: a was not assigned the correct float value (expected '$exp', got '$a')"
|
||||
|
||||
# ======
|
||||
# ${!FOO@} and ${!FOO*} expansions did not include FOO itself
|
||||
# https://github.com/ksh93/ksh/issues/183
|
||||
unset foo "${!foo@}"
|
||||
exp='foo foobar fool'
|
||||
got=$(IFS=/; foo=bar foobar=fbar fool=pity; print -r -- "${!foo@}")
|
||||
[[ $got == "$exp" ]] || err_exit "\${!foo@}: expected $(printf %q "$exp"), got $(printf %q "$got")"
|
||||
exp='foo/foobar/fool'
|
||||
got=$(IFS=/; foo=bar foobar=fbar fool=pity; print -r -- "${!foo*}")
|
||||
[[ $got == "$exp" ]] || err_exit "\${!foo*}: expected $(printf %q "$exp"), got $(printf %q "$got")"
|
||||
|
||||
# ======
|
||||
exit $((Errors<125?Errors:125))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue