Skip to content

Commit a8a98ab

Browse files
committed
refactor(scrub_git_env): loop over readonly array; tolerate readonly vars
Assisted-by: Sisyphus:claude-sonnet-4-6 opencode
1 parent 6aa3c54 commit a8a98ab

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

hooks/_common.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,16 @@ function common::parse_cmdline {
136136
# GIT_WORK_TREE pairs with GIT_DIR
137137
#######################################################################
138138
function common::scrub_git_env {
139-
unset GIT_DIR GIT_INDEX_FILE GIT_OBJECT_DIRECTORY GIT_WORK_TREE
139+
local -r git_env_vars=(
140+
GIT_DIR
141+
GIT_INDEX_FILE
142+
GIT_OBJECT_DIRECTORY
143+
GIT_WORK_TREE
144+
)
145+
local env_var
146+
for env_var in "${git_env_vars[@]}"; do
147+
unset "$env_var" 2> /dev/null || true
148+
done
140149
}
141150

142151
#######################################################################

0 commit comments

Comments
 (0)