From c4d4380a0700542796887b2e6dbd41e9a7916997 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 1 Oct 2016 20:35:10 +0200 Subject: ash: [EXPAND] Split unquoted $@/$* correctly when IFS is set but empty Upstream commit: Date: Wed, 8 Oct 2014 15:24:23 +0800 [EXPAND] Split unquoted $@/$* correctly when IFS is set but empty Currently we do not field-split $@/$* when it isn't quoted and IFS is set but empty. This is obviously wrong. This patch fixes this. Signed-off-by: Herbert Xu Signed-off-by: Denys Vlasenko --- shell/hush_test/hush-vars/var_wordsplit_ifs1.right | 25 ++++++++++++++++++++++ shell/hush_test/hush-vars/var_wordsplit_ifs1.tests | 21 ++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 shell/hush_test/hush-vars/var_wordsplit_ifs1.right create mode 100755 shell/hush_test/hush-vars/var_wordsplit_ifs1.tests (limited to 'shell/hush_test') diff --git a/shell/hush_test/hush-vars/var_wordsplit_ifs1.right b/shell/hush_test/hush-vars/var_wordsplit_ifs1.right new file mode 100644 index 000000000..efdafc70f --- /dev/null +++ b/shell/hush_test/hush-vars/var_wordsplit_ifs1.right @@ -0,0 +1,25 @@ +Testing: !IFS $* +.abc. +.d. +.e. +Testing: !IFS $@ +.abc. +.d. +.e. +Testing: !IFS "$*" +.abc d e. +Testing: !IFS "$@" +.abc. +.d e. +Testing: IFS="" $* +.abc. +.d e. +Testing: IFS="" $@ +.abc. +.d e. +Testing: IFS="" "$*" +.abcd e. +Testing: IFS="" "$@" +.abc. +.d e. +Finished diff --git a/shell/hush_test/hush-vars/var_wordsplit_ifs1.tests b/shell/hush_test/hush-vars/var_wordsplit_ifs1.tests new file mode 100755 index 000000000..532ab992e --- /dev/null +++ b/shell/hush_test/hush-vars/var_wordsplit_ifs1.tests @@ -0,0 +1,21 @@ +set -- abc "d e" + +echo 'Testing: !IFS $*' +unset IFS; for a in $*; do echo ".$a."; done +echo 'Testing: !IFS $@' +unset IFS; for a in $@; do echo ".$a."; done +echo 'Testing: !IFS "$*"' +unset IFS; for a in "$*"; do echo ".$a."; done +echo 'Testing: !IFS "$@"' +unset IFS; for a in "$@"; do echo ".$a."; done + +echo 'Testing: IFS="" $*' +IFS=""; for a in $*; do echo ".$a."; done +echo 'Testing: IFS="" $@' +IFS=""; for a in $@; do echo ".$a."; done +echo 'Testing: IFS="" "$*"' +IFS=""; for a in "$*"; do echo ".$a."; done +echo 'Testing: IFS="" "$@"' +IFS=""; for a in "$@"; do echo ".$a."; done + +echo Finished -- cgit v1.2.3