1 --- findutils-4.1.5/locate/updatedb.sh.wiget Wed Feb 23 18:04:28 2000
2 +++ findutils-4.1.5/locate/updatedb.sh Wed May 31 14:24:38 2000
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
29 $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
38 +if test -s $NEW_LOCATE_DB; then
40 - mv $LOCATE_DB.n $LOCATE_DB
41 + mv $NEW_LOCATE_DB $LOCATE_DB
44 echo "updatedb: new database would be empty" >&2
46 + rm -f $NEW_LOCATE_DB
51 -if ! bigrams=`tempfile -p updatedb`; then
52 +if ! bigrams=`$MKTEMP $TMPDIR/f.bigrams$$XXXXXX`; then
57 -if ! filelist=`tempfile -p updatedb`; then
58 +if ! filelist=`$MKTEMP $TMPDIR/f.list$$XXXXXX`; then
64 -trap 'rm -f $bigrams $filelist $LOCATE_DB.n; exit' 1 15
66 +trap 'rm -f $bigrams $filelist $NEW_LOCATE_DB; exit' 1 15
68 # Alphabetize subdirectories before file entries using tr. James says:
69 # "to get everything in monotonic collating sequence, to avoid some
71 awk '{ if (NR <= 128) print $2 }' | tr -d '\012' > $bigrams
74 -$code $bigrams < $filelist > $LOCATE_DB.n
75 +$code $bigrams < $filelist > $NEW_LOCATE_DB
77 rm -f $bigrams $filelist
79 # To reduce the chances of breaking locate while this script is running,
80 # put the results in a temp file, then rename it atomically.
81 -if test -s $LOCATE_DB.n; then
82 +if test -s $NEW_LOCATE_DB; then
84 - mv $LOCATE_DB.n $LOCATE_DB
85 + mv $NEW_LOCATE_DB $LOCATE_DB
88 echo "updatedb: new database would be empty" >&2
90 + rm -f $NEW_LOCATE_DB