3
0
Fork 0
forked from mirrors/nixpkgs

stdenv: substituteInPlace: accept multiple filenames

I don't know if getopt is available everywhere, so I did not use it.

in any case, it can be changed to use getopt in the future if
needed.
This commit is contained in:
Artturin 2022-06-29 21:04:31 +03:00
parent c30f66c6c7
commit ba1efa71ae
2 changed files with 14 additions and 5 deletions

View file

@ -913,9 +913,9 @@ substitute ./foo.in ./foo.out \
--subst-var someVar
```
### `substituteInPlace` \<file\> \<subs\> {#fun-substituteInPlace}
### `substituteInPlace` \<multiple files\> \<subs\> {#fun-substituteInPlace}
Like `substitute`, but performs the substitutions in place on the file \<file\>.
Like `substitute`, but performs the substitutions in place on the files passed.
### `substituteAll` \<infile\> \<outfile\> {#fun-substituteAll}

View file

@ -771,9 +771,18 @@ substitute() {
}
substituteInPlace() {
local fileName="$1"
shift
substitute "$fileName" "$fileName" "$@"
local -a fileNames=()
for arg in "$@"; do
if [[ "$arg" = "--"* ]]; then
break
fi
fileNames+=("$arg")
shift
done
for file in "${fileNames[@]}"; do
substitute "$file" "$file" "$@"
done
}
_allFlags() {