修复服务启动时环境变量污染

This commit is contained in:
whyour
2023-10-20 17:54:32 +08:00
parent 046239404f
commit 4938635ef4
5 changed files with 19 additions and 4 deletions
+15
View File
@@ -0,0 +1,15 @@
#!/usr/bin/env bash
store_env_vars() {
initial_vars=($(compgen -A variable))
}
restore_env_vars() {
for key in $(compgen -A variable); do
if ! [[ " ${initial_vars[@]} " =~ " $key " ]]; then
unset "$key"
fi
done
}
store_env_vars