From 2b29cc8c7539504c97dfe389b0e17edfbe6a9f53 Mon Sep 17 00:00:00 2001 From: anntnzrb Date: Sun, 21 Dec 2025 01:02:07 -0500 Subject: [PATCH 1/4] feat(install): add --help flag --- install | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/install b/install index 67690b9a385..1f6324e34e3 100755 --- a/install +++ b/install @@ -7,6 +7,33 @@ RED='\033[0;31m' ORANGE='\033[38;5;214m' NC='\033[0m' # No Color +usage() { + cat < Date: Sun, 21 Dec 2025 01:02:59 -0500 Subject: [PATCH 2/4] feat(install): add --version flag --- install | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/install b/install index 1f6324e34e3..f199595649e 100755 --- a/install +++ b/install @@ -14,28 +14,38 @@ OpenCode Installer Usage: install.sh [options] Options: - -h, --help Display this help message - -Environment variables: - VERSION Install a specific version (e.g., VERSION=1.0.180) + -h, --help Display this help message + -v, --version Install a specific version (e.g., 1.0.180) Examples: curl -fsSL https://opencode.ai/install | bash - VERSION=1.0.180 curl -fsSL https://opencode.ai/install | bash + curl -fsSL https://opencode.ai/install | bash -s -- --version 1.0.180 EOF } -for arg in "$@"; do - case "$arg" in +requested_version=${VERSION:-} + +while [[ $# -gt 0 ]]; do + case "$1" in -h|--help) usage exit 0 ;; + -v|--version) + if [[ -n "${2:-}" ]]; then + requested_version="$2" + shift 2 + else + echo -e "${RED}Error: --version requires a version argument${NC}" + exit 1 + fi + ;; + *) + shift + ;; esac done -requested_version=${VERSION:-} - raw_os=$(uname -s) os=$(echo "$raw_os" | tr '[:upper:]' '[:lower:]') case "$raw_os" in From 8f9bf80ef6567a6e4bb8d333466818b788637792 Mon Sep 17 00:00:00 2001 From: anntnzrb Date: Sun, 21 Dec 2025 01:04:10 -0500 Subject: [PATCH 3/4] feat(install): add --no-modify-path flag Skip shell config modification for users on NixOS/home-manager or other systems with immutable/declarative configurations. Also changes 'no config file found' from error to warning, allowing the install to succeed even when config files are not writable. --- install | 76 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 35 deletions(-) diff --git a/install b/install index f199595649e..4a0b4ddc3ef 100755 --- a/install +++ b/install @@ -16,6 +16,7 @@ Usage: install.sh [options] Options: -h, --help Display this help message -v, --version Install a specific version (e.g., 1.0.180) + --no-modify-path Don't modify shell config files (.zshrc, .bashrc, etc.) Examples: curl -fsSL https://opencode.ai/install | bash @@ -24,6 +25,7 @@ EOF } requested_version=${VERSION:-} +no_modify_path=false while [[ $# -gt 0 ]]; do case "$1" in @@ -40,6 +42,10 @@ while [[ $# -gt 0 ]]; do exit 1 fi ;; + --no-modify-path) + no_modify_path=true + shift + ;; *) shift ;; @@ -341,42 +347,42 @@ case $current_shell in ;; esac -config_file="" -for file in $config_files; do - if [[ -f $file ]]; then - config_file=$file - break +if [[ "$no_modify_path" != "true" ]]; then + config_file="" + for file in $config_files; do + if [[ -f $file ]]; then + config_file=$file + break + fi + done + + if [[ -z $config_file ]]; then + print_message warning "No config file found for $current_shell. You may need to manually add to PATH:" + print_message info " export PATH=$INSTALL_DIR:\$PATH" + elif [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then + case $current_shell in + fish) + add_to_path "$config_file" "fish_add_path $INSTALL_DIR" + ;; + zsh) + add_to_path "$config_file" "export PATH=$INSTALL_DIR:\$PATH" + ;; + bash) + add_to_path "$config_file" "export PATH=$INSTALL_DIR:\$PATH" + ;; + ash) + add_to_path "$config_file" "export PATH=$INSTALL_DIR:\$PATH" + ;; + sh) + add_to_path "$config_file" "export PATH=$INSTALL_DIR:\$PATH" + ;; + *) + export PATH=$INSTALL_DIR:$PATH + print_message warning "Manually add the directory to $config_file (or similar):" + print_message info " export PATH=$INSTALL_DIR:\$PATH" + ;; + esac fi -done - -if [[ -z $config_file ]]; then - print_message error "No config file found for $current_shell. Checked files: ${config_files[@]}" - exit 1 -fi - -if [[ ":$PATH:" != *":$INSTALL_DIR:"* ]]; then - case $current_shell in - fish) - add_to_path "$config_file" "fish_add_path $INSTALL_DIR" - ;; - zsh) - add_to_path "$config_file" "export PATH=$INSTALL_DIR:\$PATH" - ;; - bash) - add_to_path "$config_file" "export PATH=$INSTALL_DIR:\$PATH" - ;; - ash) - add_to_path "$config_file" "export PATH=$INSTALL_DIR:\$PATH" - ;; - sh) - add_to_path "$config_file" "export PATH=$INSTALL_DIR:\$PATH" - ;; - *) - export PATH=$INSTALL_DIR:$PATH - print_message warning "Manually add the directory to $config_file (or similar):" - print_message info " export PATH=$INSTALL_DIR:\$PATH" - ;; - esac fi if [ -n "${GITHUB_ACTIONS-}" ] && [ "${GITHUB_ACTIONS}" == "true" ]; then From 86739f449114b83c81e72424533bcd29e2a73307 Mon Sep 17 00:00:00 2001 From: anntnzrb Date: Sun, 21 Dec 2025 01:12:16 -0500 Subject: [PATCH 4/4] fix(install): warn on unknown arguments Previously unknown flags were silently ignored, which could lead to confusion if a user typos a flag (e.g., --no-modify instead of --no-modify-path). --- install | 1 + 1 file changed, 1 insertion(+) diff --git a/install b/install index 4a0b4ddc3ef..e89ca9fb70f 100755 --- a/install +++ b/install @@ -47,6 +47,7 @@ while [[ $# -gt 0 ]]; do shift ;; *) + echo -e "${ORANGE}Warning: Unknown option '$1'${NC}" >&2 shift ;; esac