3
0
Fork 0
forked from mirrors/nixpkgs

makeWrapper: add --set-default and --set-eval

After #31497 starter quoting all values, there arouse the need to left some
values evaluated.

`--set-default var value` expands to `export var=${var-value}`, where value is
not evaluated and literally assigned to var unless it is already set.

`--set-eval var value` expands to `export var=$(eval echo value)`, where value
is evaluated by `eval`.
This commit is contained in:
Orivej Desh 2017-11-17 10:11:01 +00:00
parent 035b589245
commit 4199892768

View file

@ -48,6 +48,16 @@ makeWrapper() {
value="${params[$((n + 2))]}"
n=$((n + 2))
echo "export $varName=${value@Q}" >> "$wrapper"
elif [[ "$p" == "--set-default" ]]; then
varName="${params[$((n + 1))]}"
value="${params[$((n + 2))]}"
n=$((n + 2))
echo "export $varName=\${$varName-${value@Q}}" >> "$wrapper"
elif [[ "$p" == "--set-eval" ]]; then
varName="${params[$((n + 1))]}"
value="${params[$((n + 2))]}"
n=$((n + 2))
echo "export $varName=\$(eval echo ${value@Q})" >> "$wrapper"
elif [[ "$p" == "--unset" ]]; then
varName="${params[$((n + 1))]}"
n=$((n + 1))