mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-06-23 22:07:58 +02:00
101 lines
4.2 KiB
Plaintext
101 lines
4.2 KiB
Plaintext
# 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
|
|
|
|
# direct and indirect (prefix) array expansions
|
|
IFS=' ' a=(a b) b=${!a[@]} ; declare -p b
|
|
IFS=' ' a=(a b) b="${!a[@]}"; declare -p b
|
|
IFS=' ' a=(a b) b=${!a[*]} ; declare -p b
|
|
IFS=' ' a=(a b) b="${!a[*]}"; declare -p b
|
|
|
|
IFS=':' a=(a b) b=${!a[@]} ; declare -p b
|
|
IFS=':' a=(a b) b="${!a[@]}"; declare -p b
|
|
IFS=':' a=(a b) b=${!a[*]} ; declare -p b
|
|
IFS=':' a=(a b) b="${!a[*]}"; declare -p b
|
|
|
|
IFS='' a=(a b) b=${!a[@]} ; declare -p b
|
|
IFS='' a=(a b) b="${!a[@]}"; declare -p b
|
|
IFS='' a=(a b) b=${!a[*]} ; declare -p b
|
|
IFS='' a=(a b) b="${!a[*]}"; declare -p b
|
|
|
|
IFS=' ' a=(a b) b=${a[@]} ; declare -p b
|
|
IFS=' ' a=(a b) b="${a[@]}"; declare -p b
|
|
IFS=' ' a=(a b) b=${a[*]} ; declare -p b
|
|
IFS=' ' a=(a b) b="${a[*]}"; declare -p b
|
|
|
|
IFS=':' a=(a b) b=${a[@]} ; declare -p b
|
|
IFS=':' a=(a b) b="${a[@]}"; declare -p b
|
|
IFS=':' a=(a b) b=${a[*]} ; declare -p b
|
|
IFS=':' a=(a b) b="${a[*]}"; declare -p b
|
|
|
|
IFS='' a=(a b) b=${a[@]} ; declare -p b
|
|
IFS='' a=(a b) b="${a[@]}"; declare -p b
|
|
IFS='' a=(a b) b=${a[*]} ; declare -p b
|
|
IFS='' a=(a b) b="${a[*]}"; declare -p b
|