From e0ea4a7780dd0bc9596e55fb6c59993b58eec7a5 Mon Sep 17 00:00:00 2001 From: Vladimir Trajkovski Date: Thu, 27 Jan 2022 17:31:52 +0100 Subject: [PATCH 1/2] Replace only variables present in the environment. --- envsubst-file.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/envsubst-file.sh b/envsubst-file.sh index a0fb3c3..5537a54 100755 --- a/envsubst-file.sh +++ b/envsubst-file.sh @@ -7,7 +7,7 @@ WORKDIR=/workdir for i in $(ls $WORKDIR); do echo "Processing $i ..." - envsubst < $WORKDIR/$i > /processed/$i + envsubst "$(compgen -e | awk '$0="${"$0"}"')" < $WORKDIR/$i > /processed/$i PROCESSED=true done From 32897cb930ad1385a5a0ac8ea65fc9cdbab52184 Mon Sep 17 00:00:00 2001 From: Vladimir Trajkovski Date: Fri, 28 Jan 2022 14:29:24 +0100 Subject: [PATCH 2/2] Switch to bash as compgen is a built in command in bash. --- envsubst-file.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/envsubst-file.sh b/envsubst-file.sh index 5537a54..9a7105b 100755 --- a/envsubst-file.sh +++ b/envsubst-file.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash set -e PROCESSED=false