fix: print_shell_function(), use ${1:-} instead of $1, AND use echo \
setup instead of `echo
'` 1) If people are using bash with `set -u` (enable unset variable checking), then they will get an error if they run `pyenv` in the CLI under the current setup. To avoid any errors when no positional arguments, we use ${1:-} instead of $1. 2) We find that the script looks better when using: ```bash echo \ 'pyenv() { local command=${1:-}' ``` As opposed to: ``` echo 'pyenv() { local command=${1:-}' ```
This commit is contained in:
parent
b1882cb6fe
commit
76adade69a
@ -253,7 +253,8 @@ function print_shell_function() {
|
|||||||
commands=(`pyenv-commands --sh`)
|
commands=(`pyenv-commands --sh`)
|
||||||
case "$shell" in
|
case "$shell" in
|
||||||
fish )
|
fish )
|
||||||
echo 'function pyenv
|
echo \
|
||||||
|
'function pyenv
|
||||||
set command $argv[1]
|
set command $argv[1]
|
||||||
set -e argv[1]
|
set -e argv[1]
|
||||||
|
|
||||||
@ -266,18 +267,21 @@ function print_shell_function() {
|
|||||||
end'
|
end'
|
||||||
;;
|
;;
|
||||||
ksh | ksh93 | mksh )
|
ksh | ksh93 | mksh )
|
||||||
echo 'function pyenv {
|
echo \
|
||||||
typeset command=$1'
|
'function pyenv {
|
||||||
|
typeset command=${1:-}'
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
echo 'pyenv() {
|
echo \
|
||||||
local command=$1'
|
'pyenv() {
|
||||||
|
local command=${1:-}'
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
if [ "$shell" != "fish" ]; then
|
if [ "$shell" != "fish" ]; then
|
||||||
IFS="|"
|
IFS="|"
|
||||||
echo ' [ "$#" -gt 0 ] && shift
|
echo \
|
||||||
|
' [ "$#" -gt 0 ] && shift
|
||||||
case "$command" in
|
case "$command" in
|
||||||
'"${commands[*]:-/}"')
|
'"${commands[*]:-/}"')
|
||||||
eval "$(pyenv "sh-$command" "$@")"
|
eval "$(pyenv "sh-$command" "$@")"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user