1
0
angie-conv-image/image-entry.d/99-cleanup-env.envsh

42 lines
725 B
Plaintext
Raw Normal View History

2024-07-20 16:35:39 +03:00
#!/bin/sh
__set="$-"
set +e
if [ "${IEP_TRACE}" = 1 ] ; then
log_always "NOT going to unset following variables:"
sed -E '/^./s,^,- ,' >&2
else
unset __env
while read -r __env ; do
[ -n "${__env}" ] || continue
case "${__env}" in
*\'* )
log "skipping variable (malformed): ${__env}" >&2
continue
;;
esac
log "unsetting variable: ${__env}"
unset "${__env}"
done
unset __env
fi <<-EOF
$(
cat /proc/self/environ \
| sed -zEn '/^([^=]+).*$/s//\1/p' \
| xargs -0r printf '%q\n' \
| {
f="${target_root}/j2cfg/core-preserve-environment.txt"
[ -s "$f" ] || exec cat
grep -Fxv -f "$f"
} \
| grep -E \
-e '^(NGX|PYTHON)' \
| sort -uV
)
EOF
[ -z "${__set}" ] || set -"${__set}"
unset __set