fix: reject compose env selector aliases

This commit is contained in:
Jesse_Chen
2026-07-20 16:37:42 +08:00
parent 965b0d5888
commit 26373d257b
3 changed files with 44 additions and 2 deletions
+3 -1
View File
@@ -23,8 +23,10 @@ require_selector() {
local key="$1"
local expected="$2"
local count
local definition_pattern
count="$(grep -c "^${key}=" "$ENV_FILE" || true)"
definition_pattern="^[[:space:]]*(export[[:space:]]+)?${key}([[:space:]]*=|[[:space:]]*$)"
count="$(grep -Ec "$definition_pattern" "$ENV_FILE" || true)"
if [ "$count" -ne 1 ] || ! grep -Fqx "${key}=${expected}" "$ENV_FILE"; then
echo "invalid staging selector: $key" >&2
exit 1