mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-14 20:39:55 -05:00
Make pyenv init --path
usable as a pyenv init -
substitute
We're going to eliminate the need to mandatorily use `pyenv init --path`. We can't delete it yet for backward compatibility. Besides, there's one other use case for it: to enable shims but without shell integration, e.g. for noninteractive shells. To be a full-fledged replacement for `pyenv init -` however, it needs to do rehashing.
This commit is contained in:
parent
8439f8e187
commit
6d4365a696
3 changed files with 12 additions and 1 deletions
|
@ -528,7 +528,7 @@ opposed to this idea. Here's what `eval "$(pyenv init -)"` actually does:
|
||||||
for some reason you need `pyenv` to be a real script rather than a
|
for some reason you need `pyenv` to be a real script rather than a
|
||||||
shell function, you can safely skip it.
|
shell function, you can safely skip it.
|
||||||
|
|
||||||
`eval "$(pyenv init --path)"` only does item 1.
|
`eval "$(pyenv init --path)"` only does items 1 and 3.
|
||||||
|
|
||||||
To see exactly what happens under the hood for yourself, run `pyenv init -`
|
To see exactly what happens under the hood for yourself, run `pyenv init -`
|
||||||
or `pyenv init --path`.
|
or `pyenv init --path`.
|
||||||
|
|
|
@ -57,6 +57,7 @@ function main() {
|
||||||
;;
|
;;
|
||||||
"path")
|
"path")
|
||||||
print_path
|
print_path
|
||||||
|
print_rehash
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
"print")
|
"print")
|
||||||
|
@ -64,6 +65,7 @@ function main() {
|
||||||
print_path
|
print_path
|
||||||
print_env
|
print_env
|
||||||
print_completion
|
print_completion
|
||||||
|
print_rehash
|
||||||
print_shell_function
|
print_shell_function
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
|
@ -168,7 +170,9 @@ function print_completion() {
|
||||||
if [ -r "$completion" ]; then
|
if [ -r "$completion" ]; then
|
||||||
echo "source '$completion'"
|
echo "source '$completion'"
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function print_rehash() {
|
||||||
if [ -z "$no_rehash" ]; then
|
if [ -z "$no_rehash" ]; then
|
||||||
echo 'command pyenv rehash 2>/dev/null'
|
echo 'command pyenv rehash 2>/dev/null'
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -17,6 +17,13 @@ load test_helper
|
||||||
assert_line "command pyenv rehash 2>/dev/null"
|
assert_line "command pyenv rehash 2>/dev/null"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "auto rehash for --path" {
|
||||||
|
run pyenv-init --path
|
||||||
|
assert_success
|
||||||
|
assert_line "command pyenv rehash 2>/dev/null"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@test "setup shell completions" {
|
@test "setup shell completions" {
|
||||||
root="$(cd $BATS_TEST_DIRNAME/.. && pwd)"
|
root="$(cd $BATS_TEST_DIRNAME/.. && pwd)"
|
||||||
run pyenv-init - bash
|
run pyenv-init - bash
|
||||||
|
|
Loading…
Reference in a new issue