From 9b0273faa7ae6c04124ab50587c7b13296d9fb89 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Sat, 19 Feb 2022 16:09:04 +0100 Subject: [PATCH] lib:ldb: Reformat shell scripts shfmt -f lib/ldb/ | xargs shfmt -w -p -i 0 -fn Signed-off-by: Andreas Schneider Reviewed-by: Andrew Bartlett --- lib/ldb/configure | 2 +- lib/ldb/docs/builddocs.sh | 60 +++++++------- lib/ldb/docs/installdocs.sh | 10 +-- lib/ldb/tests/init_slapd.sh | 27 +++---- lib/ldb/tests/kill_slapd.sh | 12 +-- lib/ldb/tests/ldapi_url.sh | 4 +- lib/ldb/tests/start_slapd.sh | 6 +- lib/ldb/tests/test-extended.sh | 22 +++--- lib/ldb/tests/test-generic.sh | 123 +++++++++++++++-------------- lib/ldb/tests/test-ldap.sh | 52 ++++++------ lib/ldb/tests/test-schema.sh | 3 +- lib/ldb/tests/test-soloading.sh | 5 +- lib/ldb/tests/test-sqlite3.sh | 6 +- lib/ldb/tests/test-tdb-features.sh | 45 +++++------ lib/ldb/tests/test-tdb-subunit.sh | 4 +- lib/ldb/tests/test-tdb.sh | 4 +- lib/replace/configure | 2 +- 17 files changed, 192 insertions(+), 195 deletions(-) diff --git a/lib/ldb/configure b/lib/ldb/configure index 6c931bfbf5e..8979f07581b 100755 --- a/lib/ldb/configure +++ b/lib/ldb/configure @@ -1,6 +1,6 @@ #!/bin/sh -PREVPATH=`dirname $0` +PREVPATH=$(dirname $0) if [ -f $PREVPATH/../../buildtools/bin/waf ]; then WAF=../../buildtools/bin/waf diff --git a/lib/ldb/docs/builddocs.sh b/lib/ldb/docs/builddocs.sh index 449dcb26815..b7e11d31375 100755 --- a/lib/ldb/docs/builddocs.sh +++ b/lib/ldb/docs/builddocs.sh @@ -6,8 +6,8 @@ XSLTPROC="$1" SRCDIR="$2" if [ -z "$XSLTPROC" ] || [ ! -x "$XSLTPROC" ]; then - echo "xsltproc not installed" - exit 0 + echo "xsltproc not installed" + exit 0 fi MANXSL="http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl" @@ -16,37 +16,37 @@ HTMLXSL="http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl" mkdir -p man for f in $SRCDIR/man/*.xml; do - base=`basename $f .xml` - out=man/"`basename $base`" - if [ ! -f "$out" ] || [ "$f" -nt "$out" ]; then - echo Processing manpage $f - $XSLTPROC --nonet -o "$out" "$MANXSL" $f - ret=$? - if [ "$ret" = "4" ]; then - echo "ignoring stylesheet error 4 for $MANXSL" - exit 0 + base=$(basename $f .xml) + out=man/"$(basename $base)" + if [ ! -f "$out" ] || [ "$f" -nt "$out" ]; then + echo Processing manpage $f + $XSLTPROC --nonet -o "$out" "$MANXSL" $f + ret=$? + if [ "$ret" = "4" ]; then + echo "ignoring stylesheet error 4 for $MANXSL" + exit 0 + fi + if [ "$ret" != "0" ]; then + echo "xsltproc failed with error $ret" + exit $ret + fi fi - if [ "$ret" != "0" ]; then - echo "xsltproc failed with error $ret" - exit $ret - fi - fi done for f in $SRCDIR/man/*.xml; do - base=`basename $f .xml` - out=man/"`basename $base`".html - if [ ! -f "$out" ] || [ "$f" -nt "$out" ]; then - echo Processing html $f - $XSLTPROC --nonet -o "$out" "$HTMLXSL" $f - ret=$? - if [ "$ret" = "4" ]; then - echo "ignoring stylesheet error 4 for $HTMLXSL" - exit 0 + base=$(basename $f .xml) + out=man/"$(basename $base)".html + if [ ! -f "$out" ] || [ "$f" -nt "$out" ]; then + echo Processing html $f + $XSLTPROC --nonet -o "$out" "$HTMLXSL" $f + ret=$? + if [ "$ret" = "4" ]; then + echo "ignoring stylesheet error 4 for $HTMLXSL" + exit 0 + fi + if [ "$ret" != "0" ]; then + echo "xsltproc failed with error $ret" + exit $ret + fi fi - if [ "$ret" != "0" ]; then - echo "xsltproc failed with error $ret" - exit $ret - fi - fi done diff --git a/lib/ldb/docs/installdocs.sh b/lib/ldb/docs/installdocs.sh index 6cc7b74ad51..90daf6f6154 100755 --- a/lib/ldb/docs/installdocs.sh +++ b/lib/ldb/docs/installdocs.sh @@ -4,14 +4,14 @@ MANDIR="$1" -MAN1="`/bin/ls man/*.1`" -MAN3="`/bin/ls man/*.3`" +MAN1="$(/bin/ls man/*.1)" +MAN3="$(/bin/ls man/*.3)" if [ -z "$MAN1" ] && [ -z "$MAN3" ]; then - echo "No manpages have been built" - exit 0 + echo "No manpages have been built" + exit 0 fi -mkdir -p "$MANDIR/man1" "$MANDIR/man3" +mkdir -p "$MANDIR/man1" "$MANDIR/man3" cp $MAN1 "$MANDIR/man1/" || exit 1 cp $MAN3 "$MANDIR/man3/" || exit 1 diff --git a/lib/ldb/tests/init_slapd.sh b/lib/ldb/tests/init_slapd.sh index cf06acd08b9..4629cf13974 100755 --- a/lib/ldb/tests/init_slapd.sh +++ b/lib/ldb/tests/init_slapd.sh @@ -1,20 +1,20 @@ -#!/bin/sh +#!/bin/sh if [ -z "$LDBDIR" ]; then - LDBDIR=`dirname $0`/.. - export LDBDIR + LDBDIR=$(dirname $0)/.. + export LDBDIR fi rm -rf tests/tmp/db mkdir -p tests/tmp/db if [ -f tests/tmp/slapd.pid ]; then - kill `cat tests/tmp/slapd.pid` - sleep 1 + kill $(cat tests/tmp/slapd.pid) + sleep 1 fi if [ -f tests/tmp/slapd.pid ]; then - kill -9 `cat tests/tmp/slapd.pid` - rm -f tests/tmp/slapd.pid + kill -9 $(cat tests/tmp/slapd.pid) + rm -f tests/tmp/slapd.pid fi # we don't consider a slapadd failure as a test suite failure, as it @@ -24,18 +24,17 @@ MODCONF=tests/tmp/modules.conf rm -f $MODCONF touch $MODCONF || exit 1 -slaptest -u -f $LDBDIR/tests/slapd.conf > /dev/null 2>&1 || { - echo "enabling sladp modules" -cat > $MODCONF </dev/null 2>&1 || { + echo "enabling sladp modules" + cat >$MODCONF < /dev/null && { - echo "Should have failed to add again - gave $?" - exit 1 +$VALGRIND ldbadd $LDBDIR/tests/test.ldif 2>/dev/null && { + echo "Should have failed to add again - gave $?" + exit 1 } echo "Adding LDIF with one already-existing user again - should fail" -$VALGRIND ldbadd $LDBDIR/tests/test-dup.ldif 2> /dev/null && { - echo "Should have failed to add again - gave $?" - exit 1 +$VALGRIND ldbadd $LDBDIR/tests/test-dup.ldif 2>/dev/null && { + echo "Should have failed to add again - gave $?" + exit 1 } echo "Adding again - should succeed (as previous failed)" @@ -29,19 +29,19 @@ echo "Modifying elements" $VALGRIND ldbmodify $LDBDIR/tests/test-modify.ldif || exit 1 echo "Modify LDIF with one un-met constraint - should fail" -$VALGRIND ldbadd $LDBDIR/tests/test-modify-unmet.ldif 2> /dev/null && { - echo "Should have failed to modify - gave $?" - exit 1 +$VALGRIND ldbadd $LDBDIR/tests/test-modify-unmet.ldif 2>/dev/null && { + echo "Should have failed to modify - gave $?" + exit 1 } echo "Modify LDIF with after failure of un-met constraint - should also fail" -$VALGRIND ldbadd $LDBDIR/tests/test-modify-unmet-2.ldif 2> /dev/null && { - echo "Should have failed to modify - gave $?" - exit 1 +$VALGRIND ldbadd $LDBDIR/tests/test-modify-unmet-2.ldif 2>/dev/null && { + echo "Should have failed to modify - gave $?" + exit 1 } echo "Showing modified record" -$VALGRIND ldbsearch '(uid=uham)' || exit 1 +$VALGRIND ldbsearch '(uid=uham)' || exit 1 echo "Rename entry with ldbmodify - modrdn" $VALGRIND ldbmodify $LDBDIR/tests/test-modify-modrdn.ldif || exit 1 @@ -49,33 +49,33 @@ $VALGRIND ldbmodify $LDBDIR/tests/test-modify-modrdn.ldif || exit 1 echo "Rename entry with ldbrename" OLDDN="cn=Ursula Hampster,ou=Alumni Association,ou=People,o=University of Michigan,c=TEST" NEWDN="cn=Hampster Ursula,ou=Alumni Association,ou=People,o=University of Michigan,c=TEST" -$VALGRIND ldbrename "$OLDDN" "$NEWDN" || exit 1 +$VALGRIND ldbrename "$OLDDN" "$NEWDN" || exit 1 echo "Showing renamed record" $VALGRIND ldbsearch '(uid=uham)' || exit 1 echo "Starting ldbtest" -$VALGRIND ldbtest --num-records 100 --num-searches 10 || exit 1 +$VALGRIND ldbtest --num-records 100 --num-searches 10 || exit 1 if [ $LDB_SPECIALS = 1 ]; then - echo "Adding index" - $VALGRIND ldbadd $LDBDIR/tests/test-index.ldif || exit 1 + echo "Adding index" + $VALGRIND ldbadd $LDBDIR/tests/test-index.ldif || exit 1 fi echo "Adding bad attributes - should fail" $VALGRIND ldbadd $LDBDIR/tests/test-wrong_attributes.ldif && { - echo "Should fhave failed - gave $?" - exit 1 + echo "Should fhave failed - gave $?" + exit 1 } echo "Testing indexed search" -$VALGRIND ldbsearch '(uid=uham)' || exit 1 +$VALGRIND ldbsearch '(uid=uham)' || exit 1 $VALGRIND ldbsearch '(&(objectclass=person)(objectclass=person)(objectclass=top))' || exit 1 -$VALGRIND ldbsearch '(&(uid=uham)(uid=uham))' || exit 1 -$VALGRIND ldbsearch '(|(uid=uham)(uid=uham))' || exit 1 -$VALGRIND ldbsearch '(|(uid=uham)(uid=uham)(objectclass=OpenLDAPperson))' || exit 1 -$VALGRIND ldbsearch '(&(uid=uham)(uid=uham)(!(objectclass=xxx)))' || exit 1 -$VALGRIND ldbsearch '(&(objectclass=person)(uid=uham)(!(uid=uhamxx)))' uid \* \+ dn || exit 1 +$VALGRIND ldbsearch '(&(uid=uham)(uid=uham))' || exit 1 +$VALGRIND ldbsearch '(|(uid=uham)(uid=uham))' || exit 1 +$VALGRIND ldbsearch '(|(uid=uham)(uid=uham)(objectclass=OpenLDAPperson))' || exit 1 +$VALGRIND ldbsearch '(&(uid=uham)(uid=uham)(!(objectclass=xxx)))' || exit 1 +$VALGRIND ldbsearch '(&(objectclass=person)(uid=uham)(!(uid=uhamxx)))' uid \* \+ dn || exit 1 $VALGRIND ldbsearch '(&(uid=uham)(uid=uha*)(title=*))' uid || exit 1 echo "Testing invalid search expression" @@ -89,64 +89,65 @@ $VALGRIND ldbsearch '(objectclass=)' uid || exit 1 $VALGRIND ldbsearch -b 'cn=Hampster Ursula,ou=Alumni Association,ou=People,o=University of Michigan,c=TEST' --scope=base "" sn || exit 1 echo "Test wildcard match" -$VALGRIND ldbadd $LDBDIR/tests/test-wildcard.ldif || exit 1 -$VALGRIND ldbsearch '(cn=test*multi)' || exit 1 -$VALGRIND ldbsearch '(cn=*test*multi*)' || exit 1 -$VALGRIND ldbsearch '(cn=*test_multi)' || exit 1 -$VALGRIND ldbsearch '(cn=test_multi*)' || exit 1 -$VALGRIND ldbsearch '(cn=test*multi*test*multi)' || exit 1 +$VALGRIND ldbadd $LDBDIR/tests/test-wildcard.ldif || exit 1 +$VALGRIND ldbsearch '(cn=test*multi)' || exit 1 +$VALGRIND ldbsearch '(cn=*test*multi*)' || exit 1 +$VALGRIND ldbsearch '(cn=*test_multi)' || exit 1 +$VALGRIND ldbsearch '(cn=test_multi*)' || exit 1 +$VALGRIND ldbsearch '(cn=test*multi*test*multi)' || exit 1 $VALGRIND ldbsearch '(cn=test*multi*test*multi*multi_*)' || exit 1 echo "Starting ldbtest indexed" -$VALGRIND ldbtest --num-records 100 --num-searches 500 || exit 1 +$VALGRIND ldbtest --num-records 100 --num-searches 500 || exit 1 echo "Testing one level search" -count=`$VALGRIND ldbsearch -b 'ou=Groups,o=University of Michigan,c=TEST' --scope=one 'objectclass=*' none |grep '^dn' | wc -l` +count=$($VALGRIND ldbsearch -b 'ou=Groups,o=University of Michigan,c=TEST' --scope=one 'objectclass=*' none | grep '^dn' | wc -l) if [ $count != 3 ]; then - echo returned $count records - expected 3 - exit 1 + echo returned $count records - expected 3 + exit 1 fi echo "Testing binary file attribute value" $VALGRIND ldbmodify $LDBDIR/tests/photo.ldif || exit 1 -count=`$VALGRIND ldbsearch '(cn=Hampster Ursula)' jpegPhoto | grep '^dn' | wc -l` +count=$($VALGRIND ldbsearch '(cn=Hampster Ursula)' jpegPhoto | grep '^dn' | wc -l) if [ $count != 1 ]; then - echo returned $count records - expected 1 - exit 1 + echo returned $count records - expected 1 + exit 1 fi echo "*TODO* Testing UTF8 upper lower case searches !!" echo "Testing compare" -count=`$VALGRIND ldbsearch '(cn>=t)' cn | grep '^dn' | wc -l` +count=$($VALGRIND ldbsearch '(cn>=t)' cn | grep '^dn' | wc -l) if [ $count != 1 ]; then - # only "cn: test_multi_test_multi_test_multi" (comes after "t") - # upper-cased words come before "t" - hence excluded - echo returned $count records - expected 1 - exit 1 + # only "cn: test_multi_test_multi_test_multi" (comes after "t") + # upper-cased words come before "t" - hence excluded + echo returned $count records - expected 1 + exit 1 fi $VALGRIND ldbsearch '(cn>t)' cn && exit 1 # strictly greater should not work -count=`$VALGRIND ldbsearch '(cn<=t)' cn | grep '^dn' | wc -l` +count=$($VALGRIND ldbsearch '(cn<=t)' cn | grep '^dn' | wc -l) if [ $count != 18 ]; then - # everything except "cn: test_multi_test_multi_test_multi" (comes after "t") - # upper-cased letters come before "t" - hence included - echo returned $count records - expected 18 - exit 1 + # everything except "cn: test_multi_test_multi_test_multi" (comes after "t") + # upper-cased letters come before "t" - hence included + echo returned $count records - expected 18 + exit 1 fi $VALGRIND ldbsearch '(cn