From 948e4d589b9671aea0ae5658b6f6a0316dbc9632 Mon Sep 17 00:00:00 2001 From: hobostay <110hqc@gmail.com> Date: Mon, 9 Feb 2026 11:43:44 +0800 Subject: [PATCH] fix: Improve prerelease version filtering and terminal detection This commit fixes two issues in the installation script: 1. Fix prerelease tag filtering - Previous behavior: Used `tail -1` which could return any tag (stable or prerelease) - New behavior: Filters for tags containing '-' which indicate prerelease versions (e.g., v1.0.0-beta, v1.0.0-alpha, etc.) - Uses `grep -E '\-.*refs/tags/'` to filter for prerelease patterns - Ensures `VERSION="prerelease"` actually installs a prerelease version 2. Remove redundant terminal detection - Previous behavior: Checked `[ -t 0 ] || [ -e /dev/tty ]` - The `[ -e /dev/tty ]` check tests if /dev/tty exists, not if stdin is a terminal - This is redundant and could cause issues in some environments - New behavior: Only use `[ -t 0 ]` which correctly checks if stdin is a TTY These changes improve the reliability of the installation script, especially when installing prerelease versions. Co-Authored-By: Claude Sonnet 4.5 --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index fb3d3d4..a6cd110 100755 --- a/install.sh +++ b/install.sh @@ -44,7 +44,7 @@ elif [ "${VERSION}" = "prerelease" ]; then echo "Error: git is required to install prerelease versions" >&2 exit 1 fi - VERSION="$(git ls-remote --tags https://github.com/github/copilot-cli | tail -1 | awk -F/ '{print $NF}')" + VERSION="$(git ls-remote --tags https://github.com/github/copilot-cli | grep -E '\-.*refs/tags/' | tail -1 | awk -F/ '{print $NF}')" if [ -z "$VERSION" ]; then echo "Error: Could not determine prerelease version" >&2 exit 1 @@ -149,7 +149,7 @@ if ! command -v copilot >/dev/null 2>&1; then esac # Prompt user to add to shell rc file (only if interactive) - if [ -t 0 ] || [ -e /dev/tty ]; then + if [ -t 0 ]; then echo "" printf "Would you like to add it to %s? [y/N] " "$RC_FILE" if read -r REPLY /dev/null; then