From 14a6b7ef81b41d463c68104bd30a2e8caf4993a9 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 4 Dec 2025 09:14:07 +0000 Subject: [PATCH 1/2] Fix --version flag in shell wrapper and enable static linking - Handle --version/-v and --help/-h flags in cmd_exec() so they work correctly when invoked through the shell wrapper function (fixes #11) - Add static linking (-static) for Linux builds in CI workflow to produce portable binaries without glibc dependencies (fixes #10) --- .github/workflows/build.yml | 6 +++++- src/commands.c | 12 ++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9c7b9b0..d337094 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -60,22 +60,26 @@ jobs: arch: x86_64 runner: ubuntu-latest cc: gcc + ldflags: -static - os: linux arch: aarch64 runner: ubuntu-latest cc: aarch64-linux-gnu-gcc + ldflags: -static cross: true - os: darwin arch: x86_64 runner: macos-13 cc: clang + ldflags: "" - os: darwin arch: aarch64 runner: macos-14 cc: clang + ldflags: "" steps: - name: Checkout code @@ -98,7 +102,7 @@ jobs: run: brew install ragel - name: Build - run: make CC=${{ matrix.cc }} + run: make CC=${{ matrix.cc }} LDFLAGS="${{ matrix.ldflags }}" - name: Upload build artifact uses: actions/upload-artifact@v4 diff --git a/src/commands.c b/src/commands.c index c784bd9..cb17cea 100644 --- a/src/commands.c +++ b/src/commands.c @@ -7,6 +7,7 @@ #endif #include "commands.h" +#include "config.h" #include "tui.h" #include "utils.h" #include @@ -468,6 +469,17 @@ int cmd_exec(int argc, char **argv, const char *tries_path, Mode *mode) { const char *subcmd = argv[0]; + // Handle --version and --help flags (commonly passed through shell wrapper) + if (strcmp(subcmd, "--version") == 0 || strcmp(subcmd, "-v") == 0) { + printf("try %s\n", TRY_VERSION); + return 0; + } + if (strcmp(subcmd, "--help") == 0 || strcmp(subcmd, "-h") == 0) { + // Return non-zero to signal shell wrapper to not eval the help output + // (help is printed to stderr by main.c, so we just exit here) + return 1; + } + if (strcmp(subcmd, "init") == 0) { // Delegate to init command cmd_init(argc - 1, argv + 1, tries_path); From dda957e8234d9e3d6b7968510d0d704b60d02bab Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 4 Dec 2025 09:36:06 +0000 Subject: [PATCH 2/2] Handle all flags in exec mode and bump version to 1.3.5 - Add handling for --no-colors and --no-expand-tokens flags in cmd_exec() so they work correctly when passed through the shell wrapper - Update comment to clarify these are fallbacks (main.c normally handles) - Bump version to 1.3.5 --- PKGBUILD | 2 +- VERSION | 2 +- src/commands.c | 12 +++++++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index 4b0dfcd..a1f37a4 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -1,6 +1,6 @@ # Maintainer: Tobi Lutke pkgname=try-cli -pkgver=1.3.4 +pkgver=1.3.5 pkgrel=1 pkgdesc="A fast, interactive CLI tool for managing ephemeral development workspaces" arch=('x86_64' 'aarch64') diff --git a/VERSION b/VERSION index d0149fe..80e78df 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.3.4 +1.3.5 diff --git a/src/commands.c b/src/commands.c index cb17cea..f190209 100644 --- a/src/commands.c +++ b/src/commands.c @@ -469,7 +469,8 @@ int cmd_exec(int argc, char **argv, const char *tries_path, Mode *mode) { const char *subcmd = argv[0]; - // Handle --version and --help flags (commonly passed through shell wrapper) + // Handle flags that may be passed through shell wrapper + // (normally handled by main.c, but handle here as fallback) if (strcmp(subcmd, "--version") == 0 || strcmp(subcmd, "-v") == 0) { printf("try %s\n", TRY_VERSION); return 0; @@ -479,6 +480,15 @@ int cmd_exec(int argc, char **argv, const char *tries_path, Mode *mode) { // (help is printed to stderr by main.c, so we just exit here) return 1; } + if (strcmp(subcmd, "--no-colors") == 0) { + zstr_no_colors = true; + // Continue with remaining args + return cmd_exec(argc - 1, argv + 1, tries_path, mode); + } + if (strcmp(subcmd, "--no-expand-tokens") == 0) { + zstr_disable_token_expansion = true; + return cmd_exec(argc - 1, argv + 1, tries_path, mode); + } if (strcmp(subcmd, "init") == 0) { // Delegate to init command