envsubst
envsubst copied to clipboard
${var:+FOO} mishandles empty vars
$ export empty=''
$ echo '[${empty:+FOO}]' | envsubst
[FOO]
This is not what shell does:
$ echo "[${empty:+FOO}]"
[]
Still incorrectly implemented in v1.4.3. Let's imagine to have a true/false flag based on if another env var is empty or not:
$ export NUM=123 && echo 'enabled: ${NUM:-false}${NUM:+true}' | ./envsubst
enabled: 123true
$ export NUM= && echo 'enabled: ${NUM:-false}${NUM:+true}' | ./envsubst
enabled: falsetrue