aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolfram Schneider <wosch@FreeBSD.org>2022-01-24 18:23:59 +0000
committerWolfram Schneider <wosch@FreeBSD.org>2022-01-24 18:28:30 +0000
commit829afcb5d30140cfb721de820449f61f8054d203 (patch)
treeb9eac5f51f57119682a2e903ac28472d0a4aaa37
parent0a88bd81b76675288a0e62f5687c0c6dea710bc2 (diff)
downloadsrc-829afcb5d30140cfb721de820449f61f8054d203.tar.gz
src-829afcb5d30140cfb721de820449f61f8054d203.zip
refactor script
- simpler usage of mktemp(1) - remove unnecessary checks - documentation
-rw-r--r--usr.bin/locate/locate/concatdb.sh21
1 files changed, 8 insertions, 13 deletions
diff --git a/usr.bin/locate/locate/concatdb.sh b/usr.bin/locate/locate/concatdb.sh
index d9832cfbef5a..a1afd3e71109 100644
--- a/usr.bin/locate/locate/concatdb.sh
+++ b/usr.bin/locate/locate/concatdb.sh
@@ -30,7 +30,7 @@
#
# usage: concatdb database1 ... databaseN > newdb
#
-# Sequence of databases is important.
+# Please note: the sequence of databases is important.
#
# $FreeBSD$
@@ -42,11 +42,7 @@ set -o pipefail
: ${LIBEXECDIR:=/usr/libexec}; export LIBEXECDIR
PATH=$LIBEXECDIR:/bin:/usr/bin:$PATH; export PATH
-
-umask 077 # protect temp files
-
: ${TMPDIR:=/var/tmp}; export TMPDIR;
-test -d "$TMPDIR" || TMPDIR=/var/tmp
# utilities to built locate database
: ${bigram:=locate.bigram}
@@ -54,15 +50,12 @@ test -d "$TMPDIR" || TMPDIR=/var/tmp
: ${sort:=sort}
: ${locate:=locate}
+if [ $# -lt 2 ]; then
+ echo 'usage: concatdb databases1 ... databaseN > newdb'
+ exit 1
+fi
-case $# in
- [01]) echo 'usage: concatdb databases1 ... databaseN > newdb'
- exit 1
- ;;
-esac
-
-
-bigrams=`mktemp ${TMPDIR=/tmp}/_bigrams.XXXXXXXXXX` || exit 1
+bigrams=$(mktemp -t bigrams)
trap 'rm -f $bigrams' 0 1 2 3 5 10 15
for db
@@ -75,3 +68,5 @@ for db
do
$locate -d $db /
done | $code $bigrams
+
+#EOF