From 043d47406026f259549651f5db68e65592a12755 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Sun, 23 Nov 2025 22:29:18 -0800 Subject: [PATCH] fix: Make bash completion nosort option conditional for macOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `nosort` option for bash's `complete` command is only available in Bash 4.4+. macOS ships with Bash 3.2 due to licensing, which causes CI failures with `bash: complete: nosort: invalid option name`. Check the bash version before using nosort and fall back to not using it on older versions. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- templates/bash.sh | 7 ++++++- .../integration__integration_tests__init__init_bash.snap | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/templates/bash.sh b/templates/bash.sh index cf65ab815f..9fca97087c 100644 --- a/templates/bash.sh +++ b/templates/bash.sh @@ -73,5 +73,10 @@ if command -v {{ cmd_prefix }} >/dev/null 2>&1 || [[ -n "${WORKTRUNK_BIN:-}" ]]; _clap_complete_{{ cmd_prefix }} fi } - complete -o nospace -o bashdefault -o nosort -F _wt_lazy_complete {{ cmd_prefix }} + # nosort requires Bash 4.4+ (macOS ships with 3.2) + if [[ ${BASH_VERSINFO[0]} -gt 4 || (${BASH_VERSINFO[0]} -eq 4 && ${BASH_VERSINFO[1]} -ge 4) ]]; then + complete -o nospace -o bashdefault -o nosort -F _wt_lazy_complete {{ cmd_prefix }} + else + complete -o nospace -o bashdefault -F _wt_lazy_complete {{ cmd_prefix }} + fi fi diff --git a/tests/snapshots/integration__integration_tests__init__init_bash.snap b/tests/snapshots/integration__integration_tests__init__init_bash.snap index d2e6d82608..b97f948774 100644 --- a/tests/snapshots/integration__integration_tests__init__init_bash.snap +++ b/tests/snapshots/integration__integration_tests__init__init_bash.snap @@ -185,7 +185,12 @@ wt_exec() { _clap_complete_wt fi } - complete -o nospace -o bashdefault -o nosort -F _wt_lazy_complete wt + # nosort requires Bash 4.4+ (macOS ships with 3.2) + if [[ ${BASH_VERSINFO[0]} -gt 4 || (${BASH_VERSINFO[0]} -eq 4 && ${BASH_VERSINFO[1]} -ge 4) ]]; then + complete -o nospace -o bashdefault -o nosort -F _wt_lazy_complete wt + else + complete -o nospace -o bashdefault -F _wt_lazy_complete wt + fi fi ----- stderr -----