From ad8681f0d1a20213ab7bda3e7f134e28bd53865e Mon Sep 17 00:00:00 2001 From: "git@daemon.de" Date: Sat, 16 May 2015 00:14:14 +0200 Subject: [PATCH] rm bashisms, applied port patch --- dbtool.cc | 2 +- engine.cc | 2 +- engine.h | 2 +- samples/account-db/accdb | 18 +++++++++--------- samples/locate/locate | 13 +++++-------- samples/locate/updatedb | 10 +++------- 6 files changed, 20 insertions(+), 27 deletions(-) diff --git a/dbtool.cc b/dbtool.cc index a1ae552..2355b3b 100644 --- a/dbtool.cc +++ b/dbtool.cc @@ -77,7 +77,7 @@ int main(int argc, char *argv[]) { engine.dump(); break; case 'I': - engine.from_stdin(); + engine.from_input(); break; case 's': /* select */ diff --git a/engine.cc b/engine.cc index 37ceee5..15f8d0a 100644 --- a/engine.cc +++ b/engine.cc @@ -260,7 +260,7 @@ void Engine::regexp() { /* * Insert data into the db */ -void Engine::from_stdin() { +void Engine::from_input() { init(); #ifdef HAVE_BERKELEY int err; diff --git a/engine.h b/engine.h index ec30a3a..369fb6e 100644 --- a/engine.h +++ b/engine.h @@ -117,7 +117,7 @@ class Engine { void update(); void remove(); void select(); - void from_stdin(); + void from_input(); void dump(); void regexp(); }; diff --git a/samples/account-db/accdb b/samples/account-db/accdb index 8db4e50..66a762e 100755 --- a/samples/account-db/accdb +++ b/samples/account-db/accdb @@ -20,9 +20,8 @@ db=~/.accdb # # check if dbtool version is 1.4 or higher version=`dbtool -V 2>&1 | sed 's/[a-zA-Z .]*//g'` -if [ "x$version" != "x" ]; then - let res="$version < 14" - if [ "x$res" = "x1" ]; then +if test -n "$version"; then + if test $version -lt 14; then echo "This version of dbtool does not support encryption!" exit 1 fi @@ -36,7 +35,7 @@ fi echo -n "Enter passphrase: " read PW -if [ "x$PW" = "x" ]; then +if test -z "$PW"; then echo "empty passphrase!" exit -1 fi @@ -65,7 +64,8 @@ while : do read command - if [ "x$command" = "xL" -o "x$command" = "xl" ]; then + case $command in + l|L) echo if [ -e $db ]; then # @@ -73,7 +73,7 @@ do # separator for better formatting with sed :-) dbtool -d $db -p -D -F "¶" | sed 's/¶/ => /' fi - elif [ "x$command" = "xN" -o "x$command" = "xn" ]; then + n|N) echo echo -n "Enter entry name: " read name @@ -91,18 +91,18 @@ do | dbtool -p -i -f -d $db -F "|" echo "entry $name inserted." fi - elif [ "x$command" = "xS" -o "x$command" = "xs" ]; then + s|S) echo -n "Enter search string: " read string # # search for the given key dbtool -p -d $db -s -k $string - elif [ "x$command" = "xQ" -o "x$command" = "xq" ]; then + q|Q) echo echo "Thanks for the fish." echo exit 0 - fi + esac menu done diff --git a/samples/locate/locate b/samples/locate/locate index aa4b80e..80ac47f 100755 --- a/samples/locate/locate +++ b/samples/locate/locate @@ -11,14 +11,11 @@ # compliant regular expression. # -dbtool="/usr/bin/dbtool"; -find="/usr/bin/find"; -db="/var/local/locate.db"; -sort="/bin/sort"; -regex=$1; +db="/var/db/locate.db" +regex=$1 -if [ "x$regex" != "x" ]; then - $dbtool -d $db -S -k $regex -w -R; +if test -n "$regex"; then + dbtool -d $db -S -k $regex -w -R else - echo "Usage: locate "; + echo "Usage: locate " fi diff --git a/samples/locate/updatedb b/samples/locate/updatedb index 0487d9e..34f75e4 100755 --- a/samples/locate/updatedb +++ b/samples/locate/updatedb @@ -9,11 +9,7 @@ # to search for a certain string. # -dbtool="/usr/bin/dbtool"; -find="/usr/bin/find"; -db="/var/local/locate.db"; -egrep="/bin/egrep"; -cp="/bin/cp" +db="/var/db/locate.db"; -$cp /dev/null $db; -$find / -ls | $egrep -v "^\/proc|dev|tmp" | $dbtool -d $db -i -f -R -t "^(.+?) (\/.*)$"; +echo -n > $db +find / -ls | egrep -v "^\/proc|dev|tmp" | dbtool -d $db -i -f -R -t "^(.+?) (\/.*)$";