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:
parent
c30f66c6c7
commit
ba1efa71ae
|
@ -913,9 +913,9 @@ substitute ./foo.in ./foo.out \
|
||||||
--subst-var someVar
|
--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}
|
### `substituteAll` \<infile\> \<outfile\> {#fun-substituteAll}
|
||||||
|
|
||||||
|
|
|
@ -771,9 +771,18 @@ substitute() {
|
||||||
}
|
}
|
||||||
|
|
||||||
substituteInPlace() {
|
substituteInPlace() {
|
||||||
local fileName="$1"
|
local -a fileNames=()
|
||||||
shift
|
for arg in "$@"; do
|
||||||
substitute "$fileName" "$fileName" "$@"
|
if [[ "$arg" = "--"* ]]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
fileNames+=("$arg")
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
for file in "${fileNames[@]}"; do
|
||||||
|
substitute "$file" "$file" "$@"
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
_allFlags() {
|
_allFlags() {
|
||||||
|
|
Loading…
Reference in a new issue