fix rbenv() function in ksh and dash

ksh syntax becomes:

    function rbenv {
      typeset command

`typeset` only declares a local variable if there's an explicit
`function` declaration; otherwise the variable leaks.

Other shells use this syntax:

    rbenv() {
      local command

This is for dash compatibility, which supports neither `function` nor
`typeset`.

references #205, fixes #408
This commit is contained in:
Mislav Marohnić 2013-09-28 15:58:13 +02:00
parent 31fab8cdae
commit 5ae2cac088

View file

@ -122,13 +122,25 @@ function rbenv
command rbenv "\$command" \$argv command rbenv "\$command" \$argv
end end
end end
EOS
exit 0
;;
ksh )
cat <<EOS
function rbenv {
typeset command
EOS EOS
;; ;;
* ) * )
IFS="|"
cat <<EOS cat <<EOS
rbenv() { rbenv() {
typeset command local command
EOS
;;
esac
IFS="|"
cat <<EOS
command="\$1" command="\$1"
if [ "\$#" -gt 0 ]; then if [ "\$#" -gt 0 ]; then
shift shift
@ -142,5 +154,3 @@ rbenv() {
esac esac
} }
EOS EOS
;;
esac