From 1efa87943c62065aaad65dc6d5cabdada6298eff Mon Sep 17 00:00:00 2001 From: lukem Date: Mon, 19 Apr 2004 01:05:22 +0000 Subject: [PATCH] Rework "ignorefs" behaviour: * types are added to (rather than overriding) the default list * Still use "ignorefs none" to clear the list (including the default list) * Fix argument parsing when using "none" This makes "ignorefs" much more useful if you just want to add another fstype to the default list. Simplify variable assignment. --- usr.bin/locate/locate/updatedb.sh | 30 ++++++------------------------ 1 file changed, 6 insertions(+), 24 deletions(-) diff --git a/usr.bin/locate/locate/updatedb.sh b/usr.bin/locate/locate/updatedb.sh index 62ca750047ee..daaafeecfdd0 100644 --- a/usr.bin/locate/locate/updatedb.sh +++ b/usr.bin/locate/locate/updatedb.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# $NetBSD: updatedb.sh,v 1.8 2004/02/06 14:29:51 itohy Exp $ +# $NetBSD: updatedb.sh,v 1.9 2004/04/19 01:05:22 lukem Exp $ # # Copyright (c) 1989, 1993 # The Regents of the University of California. All rights reserved. @@ -47,8 +47,7 @@ CONF=/etc/locate.conf # configuration file PATH="/bin:/usr/bin" -ignorefs_default='! -fstype local -o -fstype cd9660 -o -fstype fdesc -o -fstype kernfs -o -fstype procfs' -ignorefs=unset +ignorefs='! -fstype local -o -fstype cd9660 -o -fstype fdesc -o -fstype kernfs -o -fstype procfs' ignore= SRCHPATHS= @@ -63,34 +62,22 @@ if [ -f "$CONF" ]; then SRCHPATHS="$SRCHPATHS $args";; ignorefs) for i in $args; do - case "$args" in + case "$i" in none) ignorefs=;; *) fs=`echo "$i" | sed -e 's/^!/! -fstype /' -e t -e 's/^/-fstype /'` - case "$ignorefs" in - ''|unset) - ignorefs="$fs";; - *) ignorefs="$ignorefs -o $fs";; - esac;; + ignorefs="${ignorefs:+${ignorefs} -o }${fs}" esac done;; ignore) set -f for i in $args; do - case "$ignore" in - '') ;; - *) ignore="$ignore -o";; - esac - ignore="$ignore -path $i" + ignore="${ignore:+${ignore} -o }-path ${i}" done set +f;; ignorecontents) set -f for i in $args; do - case "$ignore" in - '') ;; - *) ignore="$ignore -o";; - esac - ignore="$ignore -path $i -print" + ignore="${ignore:+${ignore} -o }-path ${i} -print" done set +f;; workdir) @@ -107,11 +94,6 @@ if [ -f "$CONF" ]; then exec <&5 5>&- fi -# default value when "ignorefs" is absent -case "$ignorefs" in -unset) ignorefs=$ignorefs_default;; -esac - : ${SRCHPATHS:=/} # directories to be put in the database export TMPDIR