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:
Andrej730 committed 2026-10-29 21:33:21 +05:00
1 parent 9b9caf040a
commit 0dea25c4b3
2 files changed
+37 -3

No files matched your search

+3 -3
View File
@@ -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"
}
+34
View File
@@ -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