a8m / a8m/envsubst

Feature Request / Possible bug: Support nested variables enclosed by raw string

Aperta
#30 2 commenti 3 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Go
Stelle
907
Fork
96
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

I have a weird issue where envsubst is not working as expected.

When I add only a single a default variable to the right side of the experssion it will work similarly as a default POSIX shell. But when I add additional text to the default it start to do some strange behaviour.

I'll provide some examples, I believe that will be the best description.

sh use case:
``` bash
docker run --rm -it debian:buster-slim sh
# export VAR1="shouldevaluate"
# export EMPTY_VAR=""
# export MAIN_VAR="${EMPTY_VAR:-$VAR1}"
# echo $MAIN_VAR
shouldevaluate
#
#
# export MAIN_VAR="${EMPTY_VAR:-asdqwe$VAR1}"
# echo $MAIN_VAR
asdqweshouldevaluate
#
#
# export MAIN_VAR="${EMPTY_VAR:-asdqwe $VAR1 qweasd}"
# echo $MAIN_VAR
asdqwe shouldevaluate qweasd
#
#
# export MAIN_VAR="${EMPTY_VAR:-asdqwe${VAR1}qweasd}"
# echo $MAIN_VAR
asdqweshouldevaluateqweasd
```

And this happens when I try to use the same method in envsubst.
``` bash
# cat test.template
name = ${EMPTY_VAR:-$VAR1}

name = ${EMPTY_VAR:-asdqwe$VAR1}

name = ${EMPTY_VAR:-asdqwe $VAR1 qweasd}

name = ${EMPTY_VAR:-asdqwe${VAR1}qweasd}
#
#
# envsubst < test.template
name = shouldevaluate

name = asdqwe$VAR1

name = asdqwe $VAR1 qweasd

name = asdqwe${VAR1qweasd}
```

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.