mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-26 04:43:09 +03: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 New Issue
Block a user