Revision 8706
Added by Aaron Marcuse-Kubitza over 11 years ago
in_place | ||
---|---|---|
1 |
#!/bin/sh |
|
1 |
#!/bin/sh -e
|
|
2 | 2 |
# Runs a stream command on a file |
3 | 3 |
# Usage: self file command |
4 | 4 |
|
... | ... | |
9 | 9 |
onExit () { rm -f "$temp"; } |
10 | 10 |
trap onExit EXIT |
11 | 11 |
|
12 |
"$@" <"$file" >"$temp" || exit # don't update file on error
|
|
12 |
"$@" <"$file" >"$temp" # exits on error so file not updated
|
|
13 | 13 |
diff "$file" "$temp" >/dev/null && exit # don't update file if no change |
14 | 14 |
mv "$temp" "$file" |
Also available in: Unified diff
bin/in_place: use -e (exit on error) option to sh instead of adding `|| exit` after every command