git: 829afcb5d301 - main - refactor script
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 24 Jan 2022 18:30:03 UTC
The branch main has been updated by wosch: URL: https://cgit.FreeBSD.org/src/commit/?id=829afcb5d30140cfb721de820449f61f8054d203 commit 829afcb5d30140cfb721de820449f61f8054d203 Author: Wolfram Schneider <wosch@FreeBSD.org> AuthorDate: 2022-01-24 18:23:59 +0000 Commit: Wolfram Schneider <wosch@FreeBSD.org> CommitDate: 2022-01-24 18:28:30 +0000 refactor script - simpler usage of mktemp(1) - remove unnecessary checks - documentation --- usr.bin/locate/locate/concatdb.sh | 21 ++++++++------------- 1 file 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