Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

Update shell wrapper to correctly handle errors

Maximilian Roos539b42bf2411
diff --git a/src/commands/worktree.rs b/src/commands/worktree.rs
index bd454839a..d04f9a590 100644
--- a/src/commands/worktree.rs
+++ b/src/commands/worktree.rs
@@ -77,13 +77,12 @@
//!
//! ```bash
//! wt() {
-//! local script
-//! script="$("${_WORKTRUNK_CMD:-wt}" --internal "$@" 2>&2)" || {
-//! local status=$?
-//! [ -n "$script" ] && eval "$script"
-//! return "$status"
-//! }
-//! eval "$script"
+//! local script exit_code=0
+//! script="$(command "$WORKTRUNK_BIN" --internal "$@" 2>&2)" || exit_code=$?
+//! if [[ -n "$script" ]]; then
+//! eval "$script"
+//! fi
+//! return "$exit_code"
//! }
//! ```
//!
diff --git a/src/output/directive.rs b/src/output/directive.rs
index bf4934fbc..9cf8c6681 100644
--- a/src/output/directive.rs
+++ b/src/output/directive.rs
@@ -23,13 +23,12 @@
//! The shell wrapper captures stdout via command substitution and evals it:
//! ```bash
//! wt() {
-//! local script
-//! script="$("${_WORKTRUNK_CMD:-wt}" --internal "$@" 2>&2)" || {
-//! local status=$?
-//! [ -n "$script" ] && eval "$script"
-//! return "$status"
-//! }
-//! eval "$script"
+//! local script exit_code=0
+//! script="$(command "$WORKTRUNK_BIN" --internal "$@" 2>&2)" || exit_code=$?
+//! if [[ -n "$script" ]]; then
+//! eval "$script"
+//! fi
+//! return "$exit_code"
//! }
//! ```
//!