Skip to content

Commit

Permalink
Handle IFS in a sh-compatible way
Browse files Browse the repository at this point in the history
On sh shell like dash, IFS cannot be local var. Also when setting IFS
with the "IFS=$' ';" syntax $ character is also added to the IFS value.
  • Loading branch information
xdelaruelle committed Nov 11, 2017
1 parent c7c793c commit 7a36a42
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion init/bash.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ _mlre='';
if [ -n "${IFS+x}" ]; then
_mlIFS=$IFS;
fi;
IFS=$' ';
IFS=' ';
for _mlv in ${MODULES_RUN_QUARANTINE}; do
if [ "${_mlv}" = "${_mlv##*[!A-Za-z0-9_]}" -a "${_mlv}" = "${_mlv#[0-9]}" ]; then
if [ -n "`eval 'echo ${'$_mlv'+x}'`" ]; then
Expand Down
2 changes: 1 addition & 1 deletion init/ksh.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ _mlre='';
if [ -n "${IFS+x}" ]; then
_mlIFS=$IFS;
fi;
IFS=$' ';
IFS=' ';
for _mlv in ${MODULES_RUN_QUARANTINE}; do
if [ "${_mlv}" = "${_mlv##*[!A-Za-z0-9_]}" -a "${_mlv}" = "${_mlv#[0-9]}" ]; then
if [ -n "`eval 'echo ${'$_mlv'+x}'`" ]; then
Expand Down
2 changes: 1 addition & 1 deletion init/sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ _mlre='';
if [ -n "${IFS+x}" ]; then
_mlIFS=$IFS;
fi;
IFS=$' ';
IFS=' ';
for _mlv in ${MODULES_RUN_QUARANTINE}; do
if [ "${_mlv}" = "${_mlv##*[!A-Za-z0-9_]}" -a "${_mlv}" = "${_mlv#[0-9]}" ]; then
if [ -n "`eval 'echo ${'$_mlv'+x}'`" ]; then
Expand Down
2 changes: 1 addition & 1 deletion init/zsh.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ _mlre='';
if [ -n "${IFS+x}" ]; then
_mlIFS=$IFS;
fi;
IFS=$' ';
IFS=' ';
for _mlv in ${=MODULES_RUN_QUARANTINE}; do
if [ "${_mlv}" = "${_mlv##*[!A-Za-z0-9_]}" -a "${_mlv}" = "${_mlv#[0-9]}" ]; then
if [ -n "`eval 'echo ${'$_mlv'+x}'`" ]; then
Expand Down
2 changes: 1 addition & 1 deletion modulecmd.tcl.in
Original file line number Diff line number Diff line change
Expand Up @@ -2594,7 +2594,7 @@ if ( ! \$?histchars && ! \$?prompt ) alias module '$eval_cmd' ;"
if \[ -n \"\${IFS+x}\" \]; then
$locf _mlIFS=\$IFS;
fi;
$locf IFS=\$' ';
IFS=' ';
for _mlv in \${${wsplit}MODULES_RUN_QUARANTINE}; do"
append fdef {
if [ "${_mlv}" = "${_mlv##*[!A-Za-z0-9_]}" -a "${_mlv}" = "${_mlv#[0-9]}" ]; then
Expand Down
6 changes: 3 additions & 3 deletions testsuite/modules.70-maint/120-autoinit.exp
Original file line number Diff line number Diff line change
Expand Up @@ -88,21 +88,21 @@ set func_quar_sh "\\s*local _mlre=''; local _mlv; local _mlrv;
\\s*if \\\[ -n \"\\\${IFS\\\+x}\" \\\]; then
\\s*local _mlIFS=\\\$IFS;
\\s*fi;
\\s*local IFS=\\\$' ';
\\s*IFS=' ';
\\s*for _mlv in \\\${MODULES_RUN_QUARANTINE}; do
$end_quar_sh"
set func_quar_zsh "\\s*typeset _mlre=''; typeset _mlv; typeset _mlrv;
\\s*if \\\[ -n \"\\\${IFS\\\+x}\" \\\]; then
\\s*typeset _mlIFS=\\\$IFS;
\\s*fi;
\\s*typeset IFS=\\\$' ';
\\s*IFS=' ';
\\s*for _mlv in \\\${=MODULES_RUN_QUARANTINE}; do
$end_quar_sh"
set func_quar_sh_other "\\s*typeset _mlre=''; typeset _mlv; typeset _mlrv;
\\s*if \\\[ -n \"\\\${IFS\\\+x}\" \\\]; then
\\s*typeset _mlIFS=\\\$IFS;
\\s*fi;
\\s*typeset IFS=\\\$' ';
\\s*IFS=' ';
\\s*for _mlv in \\\${MODULES_RUN_QUARANTINE}; do
$end_quar_sh"
set func_clean_ifs "\\s*if \\\[ -n \"\\\${_mlIFS\\\+x}\" \\\]; then
Expand Down

0 comments on commit 7a36a42

Please sign in to comment.