Project

General

Profile

« Previous | Next » 

Revision 13309

bin/in_place: diff: use --brief to avoid scanning the entire file for large files

View differences:

in_place
1 1
#!/bin/sh -e
2 2
# Runs a stream command on a file
3
# Usage: [preserve_mtime=1] self file command
3
# Usage: [preserve_mtime=1] [preserve_mtime=1] self file command
4 4

  
5 5
file="$1"
6 6
shift
......
12 12
trap onExit EXIT
13 13

  
14 14
"$@" <"$file" >"$temp" # exits on error so file not updated
15
diff "$file" "$temp" >/dev/null && exit # don't update file if no change
15
diff --brief "$file" "$temp" >/dev/null && exit # don't update file if no change
16
	# --brief: avoid scanning the entire file for large files
16 17
if test "$preserve_mtime"; then touch -r "$file" "$temp"; fi
17 18
case "$(uname)" in Linux) chmod --reference="$file" "$temp";; esac
18 19
mv "$temp" "$file"

Also available in: Unified diff