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`)
|
||||
case "$shell" in
|
||||
fish )
|
||||
echo 'function pyenv
|
||||
echo \
|
||||
'function pyenv
|
||||
set command $argv[1]
|
||||
set -e argv[1]
|
||||
|
||||
@ -266,18 +267,21 @@ function print_shell_function() {
|
||||
end'
|
||||
;;
|
||||
ksh | ksh93 | mksh )
|
||||
echo 'function pyenv {
|
||||
typeset command=$1'
|
||||
echo \
|
||||
'function pyenv {
|
||||
typeset command=${1:-}'
|
||||
;;
|
||||
* )
|
||||
echo 'pyenv() {
|
||||
local command=$1'
|
||||
echo \
|
||||
'pyenv() {
|
||||
local command=${1:-}'
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "$shell" != "fish" ]; then
|
||||
IFS="|"
|
||||
echo ' [ "$#" -gt 0 ] && shift
|
||||
echo \
|
||||
' [ "$#" -gt 0 ] && shift
|
||||
case "$command" in
|
||||
'"${commands[*]:-/}"')
|
||||
eval "$(pyenv "sh-$command" "$@")"
|
||||
|
Loading…
x
Reference in New Issue
Block a user