diff options
author | Scott Moser <smoser@ubuntu.com> | 2012-11-08 09:35:36 -0500 |
---|---|---|
committer | Scott Moser <smoser@ubuntu.com> | 2012-11-08 09:35:36 -0500 |
commit | 6240367f1e87b077c81a8af2883cd4b50f64d76b (patch) | |
tree | e4176833eccfae4531faa8ed3df22eae0c52a047 | |
parent | 1e6fc277a1c8d695c37741cc31f5ddab3d5b5600 (diff) | |
parent | 956e94d16ab9c94471d3829424e8bd5183f3a735 (diff) | |
download | vyos-cloud-init-6240367f1e87b077c81a8af2883cd4b50f64d76b.tar.gz vyos-cloud-init-6240367f1e87b077c81a8af2883cd4b50f64d76b.zip |
improve zsh support in tools/Z99-cloud-locale-test.sh
This change does 3 things:
* revert the fix from revno 697
* minor clean up some local variable usage and definition
* make Z99-cloud-locale-test.sh actually work when shell is zsh
the last is done by detecting if this is zsh, and if so, changing the zsh
behavior for this function to emulate sh. As a result of the '-L' in
'emulate -L sh', we have no negative affect on the user's shell.
LP: #1073077
-rwxr-xr-x | tools/Z99-cloud-locale-test.sh | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/tools/Z99-cloud-locale-test.sh b/tools/Z99-cloud-locale-test.sh index 4012beeb..3c51f22d 100755 --- a/tools/Z99-cloud-locale-test.sh +++ b/tools/Z99-cloud-locale-test.sh @@ -10,10 +10,13 @@ # locale_warn() { - local cr=" -" - local bad_names="" bad_lcs="" key="" value="" var="" + local bad_names="" bad_lcs="" key="" val="" var="" vars="" local w1 w2 w3 w4 remain + + # if shell is zsh, act like sh only for this function (-L). + # The behavior change will not permenently affect user's shell. + [ "${ZSH_NAME+zsh}" = "zsh" ] && emulate -L sh + # locale is expected to output either: # VARIABLE= # VARIABLE="value" @@ -22,7 +25,7 @@ locale_warn() { case "$w1" in locale:) bad_names="${bad_names} ${w4}";; *) - key=${w1%%\=*} + key=${w1%%=*} val=${w1#*=} val=${val#\"} val=${val%\"} @@ -31,10 +34,10 @@ locale_warn() { done for bad in $bad_names; do for var in ${vars}; do - [ "${bad}" = "${var%\=*}" ] || continue - value=${var#*=} - [ "${bad_lcs#* ${value}}" = "${bad_lcs}" ] && - bad_lcs="${bad_lcs} ${value}" + [ "${bad}" = "${var%=*}" ] || continue + val=${var#*=} + [ "${bad_lcs#* ${val}}" = "${bad_lcs}" ] && + bad_lcs="${bad_lcs} ${val}" break done done |