1 --- findutils-4.1/locate/updatedb.sh.mktemp Mon Mar 2 18:02:21 1998
2 +++ findutils-4.1/locate/updatedb.sh Mon Mar 2 18:40:06 1998
7 +if test -x /bin/mktemp; then
8 + : ${MKTEMP=/bin/mktemp}
10 + : ${MKTEMP=/bin/touch}
13 # The user to search network directories as.
18 if test $old = no; then
20 +NEW_LOCATE_DB=`$MKTEMP $LOCATE_DB.n.XXXXXX` || {
21 + echo "could not create temporary locate db" >&2
25 # FIXME figure out how to sort null-terminated strings, and use -print0.
27 if test -n "$SEARCHPATHS"; then
30 "$find $NETPATHS \\( -type d -regex \"$PRUNEREGEX\" -prune \\) -o -print"
32 -} | sort -f | $frcode > $LOCATE_DB.n
33 +} | sort -f | $frcode > $NEW_LOCATE_DB
35 # To avoid breaking locate while this script is running, put the
36 # results in a temp file, then rename it atomically.
37 -if test -s $LOCATE_DB.n; then
39 - mv $LOCATE_DB.n $LOCATE_DB
40 +if test -s $NEW_LOCATE_DB; then
41 + # try atomic move first; mv may not have -f flag on some systems
42 + mv -f $NEW_LOCATE_DB $LOCATE_DB >/dev/null 2>&1 || {
43 + # for systems whose mv does not grok -f
45 + mv $NEW_LOCATE_DB $LOCATE_DB
49 echo "updatedb: new database would be empty" >&2
51 + rm -f $NEW_LOCATE_DB
56 -bigrams=$TMPDIR/f.bigrams$$
57 -filelist=$TMPDIR/f.list$$
58 +bigrams=`$MKTEMP $TMPDIR/f.bigrams$$XXXXXX`
59 +filelist=`$MKTEMP $TMPDIR/f.list$$XXXXXX`
60 trap 'rm -f $bigrams $filelist; exit' 1 15
62 # Alphabetize subdirectories before file entries using tr. James says: