From 8f5758aa37650d355814211e2ac55894f2326ff5 Mon Sep 17 00:00:00 2001 From: muava12 Date: Mon, 23 Feb 2026 03:04:07 +0800 Subject: [PATCH] fix(installer): use POSIX-compatible version detection and fix pipe input [skip ci] --- install_picoclaw.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/install_picoclaw.sh b/install_picoclaw.sh index a2cf989c0..9ffcc3788 100644 --- a/install_picoclaw.sh +++ b/install_picoclaw.sh @@ -69,7 +69,9 @@ fi # Check if already installed if [ -f "$INSTALL_DIR/$BINARY_NAME" ]; then - INSTALLED_VERSION=$("$INSTALL_DIR/$BINARY_NAME" --version 2>/dev/null | grep -oP '\d+\.\d+\.\d+' | head -1) + INSTALLED_VERSION=$("$INSTALL_DIR/$BINARY_NAME" --version 2>/dev/null | sed -n 's/.*\(v\?[0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*[^ ]*\).*/\1/p' | head -1) + # Strip 'v' prefix if present + INSTALLED_VERSION=${INSTALLED_VERSION#v} if [ -n "$INSTALLED_VERSION" ]; then print_success "Already installed: $BINARY_NAME v$INSTALLED_VERSION" @@ -85,9 +87,13 @@ if [ -f "$INSTALL_DIR/$BINARY_NAME" ]; then exit 0 else echo "" - echo -e "${YELLOW}!${RESET} Update available: v$INSTALLED_VERSION → $VERSION" + echo -e "${BLUE}!${RESET} Update available: v$INSTALLED_VERSION → $VERSION" echo "" - read -p "Do you want to update? [y/N] " -n 1 -r + if [ -t 0 ]; then + read -p "Do you want to update? [y/N] " -n 1 -r + else + read -p "Do you want to update? [y/N] " -n 1 -r < /dev/tty + fi echo "" if [[ ! $REPLY =~ ^[Yy]$ ]]; then print_step "Update cancelled"