mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 23:20:55 +00:00
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:
parent
035b589245
commit
4199892768
|
@ -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))
|
||||
|
|
Loading…
Reference in a new issue