Fix borked version display for mksh

`"$SHELL" -c "printf %s \$KSH_VERSION"` as part of the shell version
detection for ksh and mksh was expanding to `printf %s $KSH_VERSION`
inside of shell. This resulted in `$KSH_VERSION` being substituted as
multiple arguments to printf. While (afaik) unspecified, mksh, bash
and zsh resort to repeating the format strings. This resulted in all
spaces missing from `$shell`, which in turn caused the string cleanup
to fail: `Shell: mksh @MIRBSDKSHR562017/08/29`

Quoting `$KSH_VERSION` causes it to be given to printf as a single
argument, which preserves its spaces. The output after this change
looks like follows: `Shell: mksh R56 2017/08/29`
This commit is contained in:
Ain 2018-07-17 11:37:23 +00:00
parent 71df4ffd3b
commit f960594cd4

View file

@ -1366,7 +1366,7 @@ get_shell() {
"sh" | "ash" | "dash") ;; "sh" | "ash" | "dash") ;;
"mksh" | "ksh") "mksh" | "ksh")
shell+="$("$SHELL" -c "printf %s \$KSH_VERSION")" shell+="$("$SHELL" -c "printf %s \"\$KSH_VERSION\"")"
shell="${shell/ * KSH}" shell="${shell/ * KSH}"
shell="${shell/version}" shell="${shell/version}"
;; ;;