1
0
angie-conv-image/scripts/envsubst-args.sh

24 lines
525 B
Bash
Raw Normal View History

2024-09-17 14:11:00 +03:00
#!/bin/sh
set -f
2024-09-30 20:54:31 +03:00
sed -znE '/^([^=]+)=.*$/s,,\1,p' /proc/$$/environ \
2024-09-17 14:11:00 +03:00
| sed -zE \
2024-11-18 11:30:16 +03:00
-e '/^_$/d' \
2024-09-17 14:11:00 +03:00
-e '/^__IEP_/d;/^IEP_$/d' \
2024-11-18 11:30:16 +03:00
-e '/^NGX_TEMPLATE_(EX|IN)CLUDE/d' \
-e '/^ENVSUBST_/d' \
-e '/^J2CFG_/d' \
-e '/^ANGIE(|_BPF_MAPS)$/d' \
2024-09-17 14:11:00 +03:00
| {
if [ -n "${ENVSUBST_EXCLUDE_REGEX:-}" ] ; then
grep -zEv -e "${ENVSUBST_EXCLUDE_REGEX}"
2024-09-30 20:54:31 +03:00
elif [ -n "${ENVSUBST_INCLUDE_REGEX:-}" ] ; then
grep -zE -e "${ENVSUBST_INCLUDE_REGEX}"
2024-09-17 14:11:00 +03:00
else
2024-09-30 20:54:31 +03:00
cat
2024-09-17 14:11:00 +03:00
fi
} \
| sort -zV \
| xargs -0 -r printf '${%s} ' \
| sed -zE 's/ $//'