mirror of
https://github.com/apisnetworks/pyenv.git
synced 2026-11-30 19:59:01 +00:00
Initialize summary/usage/help local vars
Fix currently broken `pyenv --help` when `.dylib` was compiled pyenv/libexec/pyenv-help: line 105: summary: unbound variable And also return support for commands missing summary/usage/help (it broke after `set -u` was added recently to all scripts, so the use of variables got more strict).
This commit is contained in:
1 parent
9b9caf040a
commit
0dea25c4b3
2 files changed
+37
-3
No files matched your search
+3
-3
@@ -99,7 +99,7 @@ documentation_for() {
|
||||
|
||||
print_summary() {
|
||||
local command="$1"
|
||||
local summary usage help
|
||||
local summary="" usage="" help=""
|
||||
eval "$(documentation_for "$command")"
|
||||
|
||||
if [ -n "$summary" ]; then
|
||||
@@ -115,7 +115,7 @@ print_summaries() {
|
||||
|
||||
print_help() {
|
||||
local command="$1"
|
||||
local summary usage help
|
||||
local summary="" usage="" help=""
|
||||
eval "$(documentation_for "$command")"
|
||||
[ -n "$help" ] || help="$summary"
|
||||
|
||||
@@ -138,7 +138,7 @@ print_help() {
|
||||
|
||||
print_usage() {
|
||||
local command="$1"
|
||||
local summary usage help
|
||||
local summary="" usage="" help=""
|
||||
eval "$(documentation_for "$command")"
|
||||
[ -z "$usage" ] || echo "$usage"
|
||||
}
|
||||
|
||||
@@ -14,6 +14,40 @@ load test_helper
|
||||
assert_failure "pyenv: no such command \`hello'"
|
||||
}
|
||||
|
||||
@test "summary of commands skips undocumented command" {
|
||||
mkdir -p "${PYENV_TEST_DIR}/bin"
|
||||
cat > "${PYENV_TEST_DIR}/bin/pyenv-hello" <<SH
|
||||
#!shebang
|
||||
echo hello
|
||||
SH
|
||||
|
||||
run pyenv-help
|
||||
assert_success
|
||||
[[ $output != *hello* ]]
|
||||
}
|
||||
|
||||
@test "undocumented command" {
|
||||
mkdir -p "${PYENV_TEST_DIR}/bin"
|
||||
cat > "${PYENV_TEST_DIR}/bin/pyenv-hello" <<SH
|
||||
#!shebang
|
||||
echo hello
|
||||
SH
|
||||
|
||||
run pyenv-help hello
|
||||
assert_failure "Sorry, this command isn't documented yet."
|
||||
}
|
||||
|
||||
@test "usage of undocumented command" {
|
||||
mkdir -p "${PYENV_TEST_DIR}/bin"
|
||||
cat > "${PYENV_TEST_DIR}/bin/pyenv-hello" <<SH
|
||||
#!shebang
|
||||
echo hello
|
||||
SH
|
||||
|
||||
run pyenv-help --usage hello
|
||||
assert_success ""
|
||||
}
|
||||
|
||||
@test "shows help for a specific command" {
|
||||
mkdir -p "${PYENV_TEST_DIR}/bin"
|
||||
cat > "${PYENV_TEST_DIR}/bin/pyenv-hello" <<SH
|
||||
|
||||
Reference in new issue
Block a user