From 1d8a40ca4d95ed99e47af72ca7fd7046ab06b24c Mon Sep 17 00:00:00 2001 From: Jose Tiburcio Ribeiro Netto Date: Wed, 4 Mar 2026 18:20:57 -0300 Subject: [PATCH 1/2] fix(fish): preserve generated script and exit status in init wrapper Use `string collect` in the fish wrapper generated by `try init` so multi-line output from `try exec` is evaluated as one script. Also capture `pipestatus[1]` and return it on failure instead of relying on `$status` from the pipeline tail. --- src/commands.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/commands.c b/src/commands.c index 4c9092a..b2dc8f1 100644 --- a/src/commands.c +++ b/src/commands.c @@ -391,9 +391,14 @@ void cmd_init(int argc, char **argv, const char *tries_path) { // Fish shell version printf( "function try\n" - " set -l out (%s exec --path %s $argv 2>/dev/tty)\n" - " or begin; echo $out; return $status; end\n" - " eval $out\n" + " set -l out (%s exec --path %s $argv 2>/dev/tty | string collect)\n" + " set -l rc $pipestatus[1]\n" + " if test $rc -eq 0\n" + " eval $out\n" + " else\n" + " echo $out\n" + " return $rc\n" + " end\n" "end\n", zstr_cstr(&escaped_self), zstr_cstr(&escaped_tries)); } else { From 3f0b2c65a3a4235c66383feb3814d795d2577f06 Mon Sep 17 00:00:00 2001 From: Jose Tiburcio Ribeiro Netto Date: Wed, 4 Mar 2026 18:51:12 -0300 Subject: [PATCH 2/2] docs(fish): use `command try init` in setup examples Use `command try` in Fish init snippets so re-sourcing shell config always calls the binary, not an already-defined `try` function. This keeps setup idempotent and avoids recursion/weird behavior when config.fish is sourced multiple times. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 62691db..606e211 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ sudo mv try /usr/local/bin/ echo 'eval "$(try init ~/src/tries)"' >> ~/.zshrc # For fish shell users -echo 'eval (try init ~/src/tries | string collect)' >> ~/.config/fish/config.fish +echo 'eval (command try init ~/src/tries | string collect)' >> ~/.config/fish/config.fish ``` ### Build from source @@ -117,9 +117,9 @@ Not just substring matching - it's smart: - Fish: ```fish - eval (try init | string collect) + eval (command try init | string collect) # Or pick a path - eval (try init ~/code/experiments | string collect) + eval (command try init ~/code/experiments | string collect) ``` Notes: