Summary
gh_run in lib/bash/gh/lib_gh.sh is broken in scripts that use set -e (or set -euo pipefail).
Root cause
gh_run() {
local status
gh_require_cli || return 1
gh "$@" # ← unchecked: with set -e, a failing gh exits the script here
status=$? # ← never reached on failure
((status == 0)) && return 0
gh_report_command_failure "$status" "$@"
}
gh "$@" is a plain command in the function body. With set -e active, any non-zero exit from gh causes the calling script to exit immediately — before status=$? is captured. gh_report_command_failure never runs, so the caller gets a silent abrupt exit instead of a controlled error with diagnostics.
The BATS suite doesn't expose this because capture_command does set +e before calling.
Fix
gh_run() {
local status=0
gh_require_cli || return 1
gh "$@" || status=$?
((status == 0)) && return 0
gh_report_command_failure "$status" "$@"
}
The || status=$? pattern keeps gh on the left side of ||, which is exempt from set -e.
Test gap
Add a test that calls gh_run from a script with set -euo pipefail active and a fake gh that returns non-zero, verifying that gh_report_command_failure output appears rather than a silent exit.
Summary
gh_runinlib/bash/gh/lib_gh.shis broken in scripts that useset -e(orset -euo pipefail).Root cause
gh "$@"is a plain command in the function body. Withset -eactive, any non-zero exit fromghcauses the calling script to exit immediately — beforestatus=$?is captured.gh_report_command_failurenever runs, so the caller gets a silent abrupt exit instead of a controlled error with diagnostics.The BATS suite doesn't expose this because
capture_commanddoesset +ebefore calling.Fix
The
|| status=$?pattern keepsghon the left side of||, which is exempt fromset -e.Test gap
Add a test that calls
gh_runfrom a script withset -euo pipefailactive and a fakeghthat returns non-zero, verifying thatgh_report_command_failureoutput appears rather than a silent exit.