Files
codex-retry-gateway/scripts/stop-gateway.sh
T
掌星 441061fe5e Avoid passing empty args to node scripts
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.
2026-06-26 12:28:11 +08:00

37 lines
911 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
--state-root)
EXPECT_PATH_VALUE=1
;;
esac
NORMALIZED_ARGS+=("$ARG")
done
ARGS=("${NORMALIZED_ARGS[@]}")
fi
if [[ ${#ARGS[@]} -eq 0 ]]; then
"$NODE_BIN" "$SCRIPT_DIR/stop-gateway.mjs"
else
"$NODE_BIN" "$SCRIPT_DIR/stop-gateway.mjs" "${ARGS[@]}"
fi