svn commit: r214583 - head/usr.bin/locate/locate
Jilles Tjoelker
jilles at stack.nl
Sun Oct 31 11:54:01 UTC 2010
On Sun, Oct 31, 2010 at 02:36:05AM +0000, Garrett Wollman wrote:
> Author: wollman
> Date: Sun Oct 31 02:36:05 2010
> New Revision: 214583
> URL: http://svn.freebsd.org/changeset/base/214583
> Log:
> Make it possible to exclude directories by name no matter where they
> are in the filesystem from the locate database. By default, exclude
> ".zfs" directories, as users who who have set snapdir=visible and are
> taking frequent snapshots most likely do not want the snapshots
> included in the locate database.
> Modified: head/usr.bin/locate/locate/updatedb.sh
> ==============================================================================
> --- head/usr.bin/locate/locate/updatedb.sh Sun Oct 31 02:15:23 2010 (r214582)
> +++ head/usr.bin/locate/locate/updatedb.sh Sun Oct 31 02:36:05 2010 (r214583)
> @@ -52,6 +52,7 @@ PATH=$LIBEXECDIR:/bin:/usr/bin:$PATH; ex
> : ${FCODES:=/var/db/locate.database} # the database
> : ${SEARCHPATHS:="/"} # directories to be put in the database
> : ${PRUNEPATHS:="/tmp /usr/tmp /var/tmp /var/db/portsnap"} # unwanted directories
> +: ${PRUNEDIRS:=".zfs"} # unwanted directories, in any parent
This makes it impossible to use empty PRUNEDIRS as it will be changed to
".zfs". I suppose it should be changed to
: ${PRUNEDIRS=".zfs"}
There are also checks for empty SEARCHPATHS and FILESYSTEMS below which
will never trigger for the same reason.
> : ${FILESYSTEMS:="$(lsvfs | tail -n +3 | \
> egrep -vw "loopback|network|synthetic|read-only|0" | \
> cut -d " " -f1)"} # allowed filesystems
> @@ -79,6 +80,14 @@ case X"$PRUNEPATHS" in
> done;;
> esac
>
> +case X"$PRUNEDIRS" in
> + X) ;;
> + *) for dir in $PRUNEDIRS
> + do
> + excludes="$excludes -or -name $dir -type d -prune"
> + done;;
> +esac
> +
> tmp=$TMPDIR/_updatedb$$
> trap 'rm -f $tmp; rmdir $TMPDIR' 0 1 2 3 5 10 15
The X stuff seems to be here for consistency with the rest of the
script, but is unnecessary. Even in old shells, things like
case $PRUNEDIRS in
'') ;;
esac
work fine.
On the other hand, for optimal portability one should indeed still write
[ "X$FOO" = "X$BAR" ]
since
[ "$FOO" = "$BAR" ]
will not work properly for some values of $FOO and $BAR on some
only slightly old shells (e.g. FreeBSD 6.4, 7.0 sh treat [ \( = \) ]
incorrectly).
--
Jilles Tjoelker
More information about the svn-src-head
mailing list