441061fe5e
Make wrapper scripts omit the "${ARGS[@]}" expansion when no arguments are supplied. Each script now checks if ARGS is empty and invokes node with only the script path if so. Affects: scripts/install-for-current-provider.sh, scripts/launch-ui.sh, scripts/restore-codex-config.sh, scripts/start-gateway.sh, and scripts/stop-gateway.sh. This prevents an empty positional parameter from being passed to the .mjs entrypoints.
37 lines
925 B
Bash
37 lines
925 B
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
NODE_BIN="node"
|
|
ARGS=("$@")
|
|
if command -v node.exe >/dev/null 2>&1; then
|
|
NODE_BIN="node.exe"
|
|
if command -v wslpath >/dev/null 2>&1; then
|
|
SCRIPT_DIR="$(wslpath -w "$SCRIPT_DIR")"
|
|
else
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -W)"
|
|
fi
|
|
NORMALIZED_ARGS=()
|
|
EXPECT_PATH_VALUE=0
|
|
for ARG in "${ARGS[@]}"; do
|
|
if [[ "$EXPECT_PATH_VALUE" == 1 ]]; then
|
|
if command -v wslpath >/dev/null 2>&1; then
|
|
ARG="$(wslpath -w "$ARG")"
|
|
fi
|
|
EXPECT_PATH_VALUE=0
|
|
fi
|
|
case "$ARG" in
|
|
--codex-config-path|--state-root)
|
|
EXPECT_PATH_VALUE=1
|
|
;;
|
|
esac
|
|
NORMALIZED_ARGS+=("$ARG")
|
|
done
|
|
ARGS=("${NORMALIZED_ARGS[@]}")
|
|
fi
|
|
if [[ ${#ARGS[@]} -eq 0 ]]; then
|
|
"$NODE_BIN" "$SCRIPT_DIR/launch-ui.mjs"
|
|
else
|
|
"$NODE_BIN" "$SCRIPT_DIR/launch-ui.mjs" "${ARGS[@]}"
|
|
fi
|