mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-06-30 17:09:50 +02:00
fix expansion of $* and $@ in contexts where word splitting is not performed to be more consistent across different word expansions; fix pathname canonicalization when setting $BASH
This commit is contained in:
+2
-1
@@ -12,7 +12,8 @@ rm -f ${BASH_TSTOUT}
|
||||
|
||||
if [ -t 1 ]; then
|
||||
if type -P tput >/dev/null; then
|
||||
CSTART=$(tput setaf 15 setab 1) CEND=$(tput sgr0)
|
||||
# CSTART=$(tput setaf 15 setab 1) CEND=$(tput sgr0)
|
||||
CSTART=$(tput bold ; tput setab 9 ; tput setaf 7) CEND=$(tput sgr0)
|
||||
else
|
||||
# can't rely on having $'...' or printf understanding \e
|
||||
# bright red background, white foreground text
|
||||
|
||||
@@ -12,7 +12,8 @@ rm -f ${BASH_TSTOUT}
|
||||
|
||||
if [ -t 1 ]; then
|
||||
if type -P tput >/dev/null; then
|
||||
CSTART=$(tput setaf 15 setab 1) CEND=$(tput sgr0)
|
||||
# CSTART=$(tput setaf 15 setab 1) CEND=$(tput sgr0)
|
||||
CSTART=$(tput bold ; tput setab 9 ; tput setaf 7) CEND=$(tput sgr0)
|
||||
else
|
||||
# can't rely on having $'...' or printf understanding \e
|
||||
# bright red background, white foreground text
|
||||
|
||||
@@ -354,7 +354,7 @@ found
|
||||
./builtins9.sub: line 52: hash: /: Is a directory
|
||||
builtin hash -p /nosuchfile cat
|
||||
builtins10.sub
|
||||
./builtins10.sub: line 17: help: -x: invalid option
|
||||
./builtins10.sub: line 19: help: -x: invalid option
|
||||
help: usage: help [-dms] [pattern ...]
|
||||
These shell commands are defined internally. Type `help' to see this list.
|
||||
Type `help name' to find out more about the function `name'.
|
||||
@@ -495,7 +495,9 @@ A star (*) next to a name means that the command is disabled.
|
||||
getopts optstring name [arg ...] while COMMANDS; do COMMANDS-2; done
|
||||
hash [-lr] [-p pathname] [-dt] [name > { COMMANDS ; }
|
||||
help [-dms] [pattern ...]
|
||||
./builtins10.sub: line 39: help: no help topics match 'bash'. Try 'help help', 'man -k bash', or 'info bash'.
|
||||
./builtins10.sub: line 41: help: no help topics match 'bash'. Try 'help help', 'man -k bash', or 'info bash'.
|
||||
Shell commands matching pattern 'ad*x':
|
||||
./builtins10.sub: line 44: help: no help topics match 'ad*x'.
|
||||
builtins11.sub
|
||||
unlimited
|
||||
unlimited
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
#
|
||||
# have to run through sed or grep to filter out version information
|
||||
|
||||
COLUMNS=80
|
||||
|
||||
# let's exercise print-help
|
||||
help -x
|
||||
|
||||
@@ -37,3 +39,6 @@ help -- | sed 1d
|
||||
|
||||
# maybe sometime in the future this will do something
|
||||
help -- bash
|
||||
|
||||
# Tinkering with format for pattern output
|
||||
help 'ad*x'
|
||||
|
||||
@@ -446,3 +446,31 @@ declare -i a="7"
|
||||
declare -- a="42"
|
||||
FOO
|
||||
declare -u A="FOO"
|
||||
exp14.sub
|
||||
!Q= <a b c> <a:b:c>
|
||||
Q= <a b c> <a:b:c>
|
||||
!Q= <a b c> <a:b:c>
|
||||
Q= <a b c> <a:b:c>
|
||||
!Q- <a b c> <a:b:c>
|
||||
Q- <a b c> <a:b:c>
|
||||
!Q? <a b c> <a:b:c>
|
||||
Q? <a b c> <a:b:c>
|
||||
!Q+ <a b c> <a:b:c>
|
||||
Q+ <a b c> <a:b:c>
|
||||
+Q+ <a b c> <a:b:c>
|
||||
!Q: <a b c> <a:b:c>
|
||||
Q: <a:b:c> <a:b:c>
|
||||
!Q# <a b c> <a:b:c>
|
||||
Q# <a:b:c> <a:b:c>
|
||||
!Q% <a b c> <a:b:c>
|
||||
Q% <a:b:c> <a:b:c>
|
||||
!Q/ <x x x> <x:x:x>
|
||||
Q/ <x:x:x> <x:x:x>
|
||||
!Q^ <A B C> <A:B:C>
|
||||
Q^ <A:B:C> <A:B:C>
|
||||
!Q, <a b c> <a:b:c>
|
||||
Q, <a:b:c> <a:b:c>
|
||||
!Q@Q <'a' 'b' 'c'> <'a':'b':'c'>
|
||||
Q@Q <'a':'b':'c'> <'a':'b':'c'>
|
||||
!Q@A <set -- 'a':'b':'c'> <set -- 'a':'b':'c'>
|
||||
Q@A <set -- 'a':'b':'c'> <set -- 'a':'b':'c'>
|
||||
|
||||
@@ -430,3 +430,4 @@ test_runsub ./exp10.sub
|
||||
test_runsub ./exp11.sub
|
||||
test_runsub ./exp12.sub
|
||||
test_runsub ./exp13.sub
|
||||
test_runsub ./exp14.sub
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#
|
||||
# tests for quoted and unquoted expansions of $@/$* in contexts without
|
||||
# word splitting
|
||||
|
||||
set -- a b c
|
||||
OIFS="$IFS"
|
||||
|
||||
IFS=:; o=$@ s=$*; printf '!Q= <%s> <%s>\n' "$o" "$s" ; IFS=$OIFS
|
||||
IFS=:; o="$@" s="$*"; printf ' Q= <%s> <%s>\n' "$o" "$s" ; IFS=$OIFS
|
||||
IFS=:; o=${@} s=${*}; printf '!Q= <%s> <%s>\n' "$o" "$s" ; IFS=$OIFS
|
||||
IFS=:; o="${@}" s="${*}"; printf 'Q= <%s> <%s>\n' "$o" "$s" ; IFS=$OIFS
|
||||
IFS=:; o=${@-x} s=${*-x}; printf '!Q- <%s> <%s>\n' "$o" "$s" ; IFS=$OIFS
|
||||
IFS=:; o="${@-x}" s="${*-x}"; printf ' Q- <%s> <%s>\n' "$o" "$s" ; IFS=$OIFS
|
||||
IFS=:; o=${@?x} s=${*?x}; printf '!Q? <%s> <%s>\n' "$o" "$s" ; IFS=$OIFS
|
||||
IFS=:; o="${@?x}" s="${*?x}"; printf ' Q? <%s> <%s>\n' "$o" "$s" ; IFS=$OIFS
|
||||
IFS=:; o=${@+$@} s=${*+$*}; printf '!Q+ <%s> <%s>\n' "$o" "$s" ; IFS=$OIFS
|
||||
IFS=:; o="${@+$@}" s="${*+$*}"; printf ' Q+ <%s> <%s>\n' "$o" "$s" ; IFS=$OIFS
|
||||
IFS=:; o=${@+"$@"} s=${*+"$*"}; printf '+Q+ <%s> <%s>\n' "$o" "$s" ; IFS=$OIFS
|
||||
|
||||
# positional parameter substring expansion
|
||||
IFS=:; o=${@:1} s=${*:1}; printf '!Q: <%s> <%s>\n' "$o" "$s" ; IFS=$OIFS
|
||||
IFS=:; o="${@:1}" s="${*:1}"; printf 'Q: <%s> <%s>\n' "$o" "$s" ; IFS=$OIFS
|
||||
|
||||
set -- aa bb cc
|
||||
|
||||
# positional parameter pattern removal
|
||||
IFS=:; o=${@#?} s=${*#?}; printf '!Q# <%s> <%s>\n' "$o" "$s" ; IFS=$OIFS
|
||||
IFS=:; o="${@#?}" s="${*#?}"; printf 'Q# <%s> <%s>\n' "$o" "$s" ; IFS=$OIFS
|
||||
|
||||
IFS=:; o=${@%?} s=${*%?}; printf '!Q%% <%s> <%s>\n' "$o" "$s" ; IFS=$OIFS
|
||||
IFS=:; o="${@%?}" s="${*%?}"; printf 'Q%% <%s> <%s>\n' "$o" "$s" ; IFS=$OIFS
|
||||
|
||||
set -- a b c
|
||||
|
||||
# positional parameter pattern substitution
|
||||
IFS=:; o=${@/?/x} s=${*/?/x}; printf '!Q/ <%s> <%s>\n' "$o" "$s" ; IFS=$OIFS
|
||||
IFS=:; o="${@/?/x}" s="${*/?/x}"; printf 'Q/ <%s> <%s>\n' "$o" "$s" ; IFS=$OIFS
|
||||
|
||||
# positional parameter case modification
|
||||
IFS=:; o=${@^[abc]} s=${*^[abc]}; printf '!Q^ <%s> <%s>\n' "$o" "$s" ; IFS=$OIFS
|
||||
IFS=:; o="${@^[abc]}" s="${*^[abc]}"; printf 'Q^ <%s> <%s>\n' "$o" "$s" ; IFS=$OIFS
|
||||
|
||||
set -- A B C
|
||||
|
||||
IFS=:; o=${@,[ABC]} s=${*,[ABC]}; printf '!Q, <%s> <%s>\n' "$o" "$s" ; IFS=$OIFS
|
||||
IFS=:; o="${@,[ABC]}" s="${*,[ABC]}"; printf 'Q, <%s> <%s>\n' "$o" "$s" ; IFS=$OIFS
|
||||
|
||||
set -- a b c
|
||||
|
||||
# positional parameter transformation -- quoting
|
||||
IFS=:; o=${@@Q} s=${*@Q}; printf '!Q@Q <%s> <%s>\n' "$o" "$s" ; IFS=$OIFS
|
||||
IFS=:; o="${@@Q}" s="${*@Q}"; printf 'Q@Q <%s> <%s>\n' "$o" "$s" ; IFS=$OIFS
|
||||
|
||||
# positional parameter transformation -- assignment
|
||||
IFS=:; o=${@@A} s=${*@A}; printf '!Q@A <%s> <%s>\n' "$o" "$s" ; IFS=$OIFS
|
||||
IFS=:; o="${@@A}" s="${*@A}"; printf 'Q@A <%s> <%s>\n' "$o" "$s" ; IFS=$OIFS
|
||||
+2
-1
@@ -63,7 +63,8 @@ echo Any output from any test, unless otherwise noted, indicates a possible anom
|
||||
# keep track of passed and failed tests and report them
|
||||
if [ -t 1 ]; then
|
||||
if type -P tput >/dev/null; then
|
||||
CSTART=$(tput setaf 15 setab 1) CEND=$(tput sgr0)
|
||||
# CSTART=$(tput bold ; tput setaf 15 ; tput setab 1) CEND=$(tput sgr0)
|
||||
CSTART=$(tput bold ; tput setab 9 ; tput setaf 7) CEND=$(tput sgr0)
|
||||
else
|
||||
# can't rely on having $'...' or printf understanding \e
|
||||
# bright red background, white foreground text
|
||||
|
||||
Reference in New Issue
Block a user