argsh minify -t <template> -o <out> renders the template with:
```sh
envsubst '$data,$commit_sha,$version' <"${template}" >"${out}"
```
(libraries/main.sh:1563)
Two problems compound:
-
The redirect truncates ${out} before envsubst runs. If the render fails, the previously-good artifact is already destroyed — replaced by a 0-byte file. set -euo pipefail aborts after the damage.
-
envsubst may not be GNU envsubst. renvsubst is a common drop-in (lok8s installs it as envsubst), and it rejects the GNU SHELL-FORMAT positional argument:
```
ERROR: Unknown flag: $data,$commit_sha,$version
```
So a project whose own toolchain is on PATH gets a 0-byte bundle from a build that looks like it merely printed a warning.
This bit us on a published installer: install/build in lok8s writes docs/public/lo-up, which is served directly to curl -fsSL https://get.lok8s.io | sh. A build run with the project's env active silently replaced it with an empty file.
Suggested fix
Render to a temp file and mv on success, so a failed render cannot damage an existing output:
```sh
local tmp; tmp="$(mktemp)"
if ! envsubst '$data,$commit_sha,$version' <"${template}" >"${tmp}"; then
rm -f "${tmp}"
return 1
fi
[[ -s "${tmp}" ]] || { rm -f "${tmp}"; return 1; }
mv "${tmp}" "${out}"
```
Optionally also detect the flavor up front — envsubst --version | grep -q 'GNU gettext' — and fail with a clear message naming the culprit, since "Unknown flag" gives no hint that the wrong envsubst is on PATH.
argsh minify -t <template> -o <out>renders the template with:```sh
envsubst '$data,$commit_sha,$version' <"${template}" >"${out}"
```
(libraries/main.sh:1563)
Two problems compound:
The redirect truncates
${out}beforeenvsubstruns. If the render fails, the previously-good artifact is already destroyed — replaced by a 0-byte file.set -euo pipefailaborts after the damage.envsubstmay not be GNU envsubst. renvsubst is a common drop-in (lok8s installs it asenvsubst), and it rejects the GNU SHELL-FORMAT positional argument:```
ERROR: Unknown flag: $data,$commit_sha,$version
```
So a project whose own toolchain is on PATH gets a 0-byte bundle from a build that looks like it merely printed a warning.
This bit us on a published installer:
install/buildin lok8s writesdocs/public/lo-up, which is served directly tocurl -fsSL https://get.lok8s.io | sh. A build run with the project's env active silently replaced it with an empty file.Suggested fix
Render to a temp file and
mvon success, so a failed render cannot damage an existing output:```sh
local tmp; tmp="$(mktemp)"
if ! envsubst '$data,$commit_sha,$version' <"${template}" >"${tmp}"; then
rm -f "${tmp}"
return 1
fi
[[ -s "${tmp}" ]] || { rm -f "${tmp}"; return 1; }
mv "${tmp}" "${out}"
```
Optionally also detect the flavor up front —
envsubst --version | grep -q 'GNU gettext'— and fail with a clear message naming the culprit, since "Unknown flag" gives no hint that the wrong envsubst is on PATH.