fix: support installer environment controls

This commit is contained in:
Edward Frazer
2026-05-26 12:16:23 -07:00
parent fa5f8fe66f
commit 6587c570dd
2 changed files with 20 additions and 6 deletions

View File

@@ -1,5 +1,5 @@
param(
[string]$Release = "latest",
[string]$Release = $env:CODEX_RELEASE,
[switch]$NonInteractive
)
@@ -7,6 +7,14 @@ Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
$ProgressPreference = "SilentlyContinue"
if ([string]::IsNullOrWhiteSpace($Release)) {
$Release = "latest"
}
if (-not $PSBoundParameters.ContainsKey("NonInteractive") -and $env:CODEX_NON_INTERACTIVE -match "^(?i:1|true|yes)$") {
$NonInteractive = $true
}
function Write-Step {
param(
[string]$Message

View File

@@ -2,8 +2,8 @@
set -eu
RELEASE="latest"
NON_INTERACTIVE=false
RELEASE="${CODEX_RELEASE:-latest}"
NON_INTERACTIVE="${CODEX_NON_INTERACTIVE:-false}"
BIN_DIR="${CODEX_INSTALL_DIR:-$HOME/.local/bin}"
BIN_PATH="$BIN_DIR/codex"
@@ -64,6 +64,10 @@ parse_args() {
--help | -h)
cat <<EOF
Usage: install.sh [--release VERSION] [--non-interactive]
Environment:
CODEX_RELEASE Version to install; overridden by --release.
CODEX_NON_INTERACTIVE Set to 1, true, or yes to skip prompts.
EOF
exit 0
;;
@@ -548,9 +552,11 @@ classify_existing_codex() {
prompt_yes_no() {
prompt="$1"
if [ "$NON_INTERACTIVE" = true ]; then
return 1
fi
case "$NON_INTERACTIVE" in
1 | [Tt][Rr][Uu][Ee] | [Yy][Ee][Ss])
return 1
;;
esac
if ( : </dev/tty ) 2>/dev/null; then
printf '%s [y/N] ' "$prompt" >/dev/tty