]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
selftest: Reformat shell scripts
authorAndreas Schneider <asn@samba.org>
Mon, 21 Feb 2022 13:06:36 +0000 (14:06 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 3 Mar 2022 00:59:34 +0000 (00:59 +0000)
shfmt -f selftest/ | xargs shfmt -w -p -i 0 -fn

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
selftest/checkpassword_arg1.sh
selftest/gdb_backtrace
selftest/gdb_run
selftest/in_screen
selftest/ns/add_bridge_iface.sh
selftest/ns/create_bridge.sh
selftest/ns/mk_nsenter.sh
selftest/ns/nsenter-helper.sh
selftest/save.env.sh

index 42e1b5e7df5a88ce5a6330ab117c55d1fd6576b9..ecaeb2ed374900bca437ba759e3c1ffbe2792781 100755 (executable)
@@ -6,7 +6,7 @@ set -u
 
 ACCOUNT_NAME="${SAMBA_CPS_ACCOUNT_NAME}"
 INVALIDPW="$1"
-NEWPW=`cat -`
+NEWPW=$(cat -)
 
 echo -n "${NEWPW}" | grep -q "^${INVALIDPW}\$" && {
        echo "Found invalid password" >&1
index 0aad62f323386feb34efeb5fd76bd9b24c0c02a5..ec2396a630e34a6de91da5acdb7bd01cc5985920 100755 (executable)
@@ -1,6 +1,6 @@
 #!/bin/sh
 
-BASENAME=`basename $0`
+BASENAME=$(basename $0)
 
 unset LD_PRELOAD
 
@@ -11,14 +11,13 @@ fi
 
 if [ "x$PLEASE_NO_GDB_BACKTRACE" != "x" ]; then
        echo "${BASENAME}: Not running debugger because PLEASE_NO_GDB_BACKTRACE is set"
-        exit 0
+       exit 0
 fi
 
-
 # we want everything on stderr, so the program is not disturbed
 exec 1>&2
 
-UNAME=`uname`
+UNAME=$(uname)
 
 PID=$1
 BINARY=$2
@@ -30,31 +29,31 @@ test x"${PID}" = x"" && {
 
 DB_LIST="gdb"
 case "${UNAME}" in
-       #
-       # on Tru64 we need to try ladebug first
-       # because gdb crashes itself...
-       #
-       OSF1)
-               DB_LIST="ladebug ${DB_LIST}"
+#
+# on Tru64 we need to try ladebug first
+# because gdb crashes itself...
+#
+OSF1)
+       DB_LIST="ladebug ${DB_LIST}"
        ;;
-       #
-       # On solaris dbx is working way more better than gdb
-       # let's try it first
-       #
-       SunOS)
-               DB_LIST="dbx ${DB_LIST}"
+#
+# On solaris dbx is working way more better than gdb
+# let's try it first
+#
+SunOS)
+       DB_LIST="dbx ${DB_LIST}"
        ;;
-       #
-       # FreeBSD comes with a flavor that works gdb66 and one that don't gdb
-       # (gdb 6.1) let's try it first the one that works !
-       #
-       FreeBSD)
-               DB_LIST="gdb66 ${DB_LIST}"
+#
+# FreeBSD comes with a flavor that works gdb66 and one that don't gdb
+# (gdb 6.1) let's try it first the one that works !
+#
+FreeBSD)
+       DB_LIST="gdb66 ${DB_LIST}"
        ;;
 esac
 
 for DB in ${DB_LIST}; do
-       DB_BIN=`which ${DB} 2>/dev/null | grep '^/'`
+       DB_BIN=$(which ${DB} 2>/dev/null | grep '^/')
        test x"${DB_BIN}" != x"" && {
                break
        }
@@ -68,59 +67,59 @@ test x"${DB_BIN}" = x"" && {
 need_binary="no"
 case "${DB}" in
 # These debuggers need the process binary specified:
-       ladebug)
+ladebug)
        need_binary="yes"
        ;;
-       gdb66)
+gdb66)
        need_binary="yes"
        ;;
-       dbx)
+dbx)
        need_binary="yes"
        ;;
 esac
 
 test x"${need_binary}" = x"yes" && {
 
-# we first try to use /proc/${PID}/exe or /proc/{$PID}/path for solaris
-# then fallback to the binary from the commandline
-# then we search for the commandline argument with
-# 'which'
-#
+       # we first try to use /proc/${PID}/exe or /proc/{$PID}/path for solaris
+       # then fallback to the binary from the commandline
+       # then we search for the commandline argument with
+       # 'which'
+       #
        test -f "/proc/${PID}/exe" && BINARY="/proc/${PID}/exe"
-       test -f "/proc/${PID}/path/a.out" && BINARY=`ls -l /proc/${PID}/path/a.out |sed 's/.*-> //'`
+       test -f "/proc/${PID}/path/a.out" && BINARY=$(ls -l /proc/${PID}/path/a.out | sed 's/.*-> //')
        test x"${BINARY}" = x"" && BINARY="/proc/${PID}/exe"
-       test -f "${BINARY}" || BINARY=`which ${BINARY}`
-       
+       test -f "${BINARY}" || BINARY=$(which ${BINARY})
+
        test -f "${BINARY}" || {
-           echo "${BASENAME}: ERROR: Cannot find binary '${BINARY}'."
-           exit 1
+               echo "${BASENAME}: ERROR: Cannot find binary '${BINARY}'."
+               exit 1
        }
 }
 
-BATCHFILE_PRE=`mktemp --tmpdir gdb_backtrace_pre.XXXXXXXXXX`
+BATCHFILE_PRE=$(mktemp --tmpdir gdb_backtrace_pre.XXXXXXXXXX)
 test -n "${BATCHFILE_PRE}" || {
        echo "mktemp doesn't work" 1>&2
        exit 1
 }
-BATCHFILE_MAIN=`mktemp --tmpdir gdb_backtrace_main.XXXXXXXXXX`
+BATCHFILE_MAIN=$(mktemp --tmpdir gdb_backtrace_main.XXXXXXXXXX)
 test -n "${BATCHFILE_MAIN}" || {
        echo "mktemp doesn't work" 1>&2
        exit 1
 }
 case "${DB}" in
-       ladebug)
-cat << EOF  > ${BATCHFILE_PRE}
+ladebug)
+       cat <<EOF >${BATCHFILE_PRE}
 set \$stoponattach
 EOF
 
-cat << EOF  > ${BATCHFILE_MAIN}
+       cat <<EOF >${BATCHFILE_MAIN}
 where
 quit
 EOF
        ${DB_BIN} -c "${BATCHFILE_MAIN}" -i "${BATCHFILE_PRE}" -pid "${PID}" "${BINARY}"
        ;;
-       gdb66)
-cat << EOF  > ${BATCHFILE_MAIN}
+gdb66)
+       cat <<EOF >${BATCHFILE_MAIN}
 set height 1000
 bt full
 info locals
@@ -129,15 +128,15 @@ quit
 EOF
        ${DB_BIN} -x "${BATCHFILE_MAIN}" "${BINARY}" "${PID}"
        ;;
-       gdb)
-cat << EOF  > ${BATCHFILE_MAIN}
+gdb)
+       cat <<EOF >${BATCHFILE_MAIN}
 set height 0
 bt full
 thread apply all bt full
 info locals
 quit
 EOF
-       ${DB_BIN} -batch -x "${BATCHFILE_MAIN}" --pid "${PID}" < /dev/null
+       ${DB_BIN} -batch -x "${BATCHFILE_MAIN}" --pid "${PID}" </dev/null
        ;;
 dbx)
        ${DB_BIN} "where;dump;kill;quit" "${BINARY}" "${PID}"
index 42d91b8559b780dcf3125884960f67e22d6e3d45..4cc26dd8dc182ee410030865e53606a6342f6d97 100755 (executable)
@@ -4,13 +4,13 @@ ENV="$1"
 
 shift 1
 
-TMPFILE=`mktemp --tmpdir gdb_run.XXXXXXXXXX`
+TMPFILE=$(mktemp --tmpdir gdb_run.XXXXXXXXXX)
 test -n "${TMPFILE}" || {
        echo "mktemp doesn't work" 1>&2
        exit 1
 }
 
-cat << EOF  > $TMPFILE
+cat <<EOF >$TMPFILE
 run
 bt
 EOF
index 024cb50754ac66bf3ed82b04655b95e193f6cf18..d7d1b53d9201e0489ebc420f7b54c138b4b3b159 100755 (executable)
@@ -7,12 +7,12 @@ SERVERNAME="$ENVNAME"
 basedir=$TMPDIR
 
 [ -r $basedir/$SERVERNAME.pid ] && {
-    for i in {2..100}; do
-       if [ ! -r "$basedir/${SERVERNAME}-$i.pid" ]; then
-           SERVERNAME="${SERVERNAME}-$i"
-           break
-       fi
-    done
+       for i in {2..100}; do
+               if [ ! -r "$basedir/${SERVERNAME}-$i.pid" ]; then
+                       SERVERNAME="${SERVERNAME}-$i"
+                       break
+               fi
+       done
 }
 
 rm -f $basedir/$SERVERNAME.{launch,log,parent.pid,pid,status}
@@ -20,11 +20,11 @@ rm -f $basedir/$SERVERNAME.{launch,log,parent.pid,pid,status}
 # set most of the environment vars we have in the screen session too
 _ENV=""
 printenv |
-  egrep -v '^TERMCAP|^WINDOW|^SHELL|^STY|^SHLVL|^SAMBA_VALGRIND|\$' |
-  egrep '^[A-Z]' |
-  sed "s/\(^[^=]*=\)\(.*\)/export \1'\2'/g" > $basedir/$SERVERNAME.vars
+       egrep -v '^TERMCAP|^WINDOW|^SHELL|^STY|^SHLVL|^SAMBA_VALGRIND|\$' |
+       egrep '^[A-Z]' |
+       sed "s/\(^[^=]*=\)\(.*\)/export \1'\2'/g" >$basedir/$SERVERNAME.vars
 
-cat <<EOF > $basedir/$SERVERNAME.launch
+cat <<EOF >$basedir/$SERVERNAME.launch
 cd $PWD
  echo \$\$ > $basedir/$SERVERNAME.pid
  . $basedir/$SERVERNAME.vars
@@ -36,58 +36,59 @@ cd $PWD
 EOF
 pid=$$
 
-cleanup() {
-    trap "exit 1" SIGINT SIGTERM SIGPIPE
-    [ -r $basedir/$SERVERNAME.status ] && {
-       read status < $basedir/$SERVERNAME.status
-       echo "$(date) samba exited with status $status" >> $basedir/$SERVERNAME.log
-       exit $status
-    }
+cleanup()
+{
+       trap "exit 1" SIGINT SIGTERM SIGPIPE
+       [ -r $basedir/$SERVERNAME.status ] && {
+               read status <$basedir/$SERVERNAME.status
+               echo "$(date) samba exited with status $status" >>$basedir/$SERVERNAME.log
+               exit $status
+       }
 
-    case $ENVNAME in
-       *.nmbd|*.smbd|*.winbindd|*.samba|*.samba_dcerpcd)
-           kill $(cat $basedir/../"${ENVNAME%\.*}"/pid/"${ENVNAME##*\.}".pid)
-           ;;
-    esac
+       case $ENVNAME in
+       *.nmbd | *.smbd | *.winbindd | *.samba | *.samba_dcerpcd)
+               kill $(cat $basedir/../"${ENVNAME%\.*}"/pid/"${ENVNAME##*\.}".pid)
+               ;;
+       esac
 
-    read pid < $basedir/$SERVERNAME.pid
-    echo "$(date) Killing samba pid $pid from $$" >> $basedir/$SERVERNAME.log
-    if [ "$pid" = "$$" ]; then
+       read pid <$basedir/$SERVERNAME.pid
+       echo "$(date) Killing samba pid $pid from $$" >>$basedir/$SERVERNAME.log
+       if [ "$pid" = "$$" ]; then
+               exit 1
+       fi
+       kill -9 $pid 2>&1
        exit 1
-    fi
-    kill -9 $pid 2>&1
-    exit 1
 }
 
-echo $$ > $basedir/$SERVERNAME.parent.pid
+echo $$ >$basedir/$SERVERNAME.parent.pid
 trap cleanup SIGINT SIGTERM SIGPIPE
 
 if [[ "$TMUX" ]]; then
-    TMUX_CMD=tmux
-    if [[ $TMUX = *tmate* ]]; then
-        TMUX_CMD=tmate
-    fi
+       TMUX_CMD=tmux
+       if [[ $TMUX = *tmate* ]]; then
+               TMUX_CMD=tmate
+       fi
 
-    $TMUX_CMD new-window -n test:$SERVERNAME "bash $basedir/$SERVERNAME.launch"
+       $TMUX_CMD new-window -n test:$SERVERNAME "bash $basedir/$SERVERNAME.launch"
 
-    # tmux seems to lag a bit for new sessions. Don't create them too
-    # quickly one after another
-    sleep .1
+       # tmux seems to lag a bit for new sessions. Don't create them too
+       # quickly one after another
+       sleep .1
 else
-    screen -r -X screen -t test:$SERVERNAME bash $basedir/$SERVERNAME.launch
+       screen -r -X screen -t test:$SERVERNAME bash $basedir/$SERVERNAME.launch
 fi
-echo "$(date) waiting in $$" >> $basedir/$SERVERNAME.log
+echo "$(date) waiting in $$" >>$basedir/$SERVERNAME.log
 read stdin_var
-echo "$(date) EOF on stdin" >> $basedir/$SERVERNAME.log
+echo "$(date) EOF on stdin" >>$basedir/$SERVERNAME.log
 
 case $ENVNAME in
-    *.nmbd|*.smbd|*.winbindd|*.samba|*.samba_dcerpcd)
+*.nmbd | *.smbd | *.winbindd | *.samba | *.samba_dcerpcd)
        kill $(cat $basedir/../"${ENVNAME%\.*}"/pid/"${ENVNAME##*\.}".pid)
        ;;
 esac
 
-read pid < $basedir/$SERVERNAME.pid
-echo "$(date) killing $pid" >> $basedir/$SERVERNAME.log
-kill $pid 2> /dev/null
-echo "$(date) exiting" >> $basedir/$SERVERNAME.log
+read pid <$basedir/$SERVERNAME.pid
+echo "$(date) killing $pid" >>$basedir/$SERVERNAME.log
+kill $pid 2>/dev/null
+echo "$(date) exiting" >>$basedir/$SERVERNAME.log
 exit 0
index da9d53a5987b506c8ade29362621e7a6f39c0773..4090319cf70f28fe77eb09cc0518eaae6ed5b8f5 100755 (executable)
@@ -10,13 +10,11 @@ bridge=$2
 
 # we need to wait for the child namespace to start up and add the new
 # interface back to our new namespace
-while ! ip link show $interface > /dev/null 2>&1
-do
-    sleep 0.1
-    echo "Waiting for $interface to be created..."
+while ! ip link show $interface >/dev/null 2>&1; do
+       sleep 0.1
+       echo "Waiting for $interface to be created..."
 done
 
 # bring the bridge-end of the link up and add it to the bridge
 ip link set dev $interface up
 ip link set $interface master $bridge
-
index 9766cd8a565bb9246ba93f33c59c34acdef24824..74f7ecafedc7ae3c0316cded56835ade6e0db863 100755 (executable)
@@ -15,5 +15,3 @@ ip link add $br_name type bridge
 ip addr add $ip_addr/24 dev $br_name
 ip addr add $ipv6_addr/112 dev $br_name
 ip link set $br_name up
-
-
index f175d6bae73a2221ed6e8564689785084fd44602..c97fda9ea44107a663e9dfbee9636a39d39c0505 100755 (executable)
@@ -23,10 +23,9 @@ helper_script="$(dirname $0)/nsenter-helper.sh $exports_file"
 
 # generate the dynamic script
 dyn_script="$(dirname $2)/nsenter.sh"
-echo "#!/bin/sh" > $dyn_script
-echo "$nsenter_cmd $helper_script" >> $dyn_script
+echo "#!/bin/sh" >$dyn_script
+echo "$nsenter_cmd $helper_script" >>$dyn_script
 chmod 755 $dyn_script
 
 # return the script we created
 echo "$dyn_script"
-
index f396ed4d98cd568e47b1ac5372c64a07a508d1af..4242227eaaeddfe3f5e79c872b158b9eb5f3a7fd 100755 (executable)
@@ -4,9 +4,9 @@
 # session to a given namespace testenv. This basically just sets up the same
 # environment variables as you normally get with selftest, for convenience.
 
-if [ $# -lt 1 ] ; then
-    echo "Usage: $0 <exports-file>"
-    exit 1
+if [ $# -lt 1 ]; then
+       echo "Usage: $0 <exports-file>"
+       exit 1
 fi
 
 # we get passed a exports file with all the environment variables defined
@@ -14,11 +14,11 @@ exports_file=$1
 
 # read the exports file so the new shell has appropriate variables setup
 # (we export rather than sourcing here so they get inherited by the subshell)
-while read -r line ; do
-    export $line
-    # dump them for the user too
-    echo $line
-done < $exports_file
+while read -r line; do
+       export $line
+       # dump them for the user too
+       echo $line
+done <$exports_file
 
 echo ""
 echo "Entered $NETBIOSNAME namespace, with above variables defined."
@@ -27,5 +27,3 @@ echo ""
 
 # start a shell session in the new namespace
 $SHELL
-
-
index 9906f95e1ae552de180c763c104d1737138a7547..ff9ba32933f918fd450a662be13e3e185cea87d1 100755 (executable)
@@ -1,15 +1,15 @@
 #!/bin/sh
 
 {
-       vars=`set | \
-               grep "^[a-zA-Z][^=]*='[^']*'$" | \
-               grep -v '^IFS=' | \
-               grep -v '^TERM' | \
-               grep -v '^PPID' | \
-               grep -v '^PS[1-9]=' | \
-               cat `
+       vars=$(set |
+               grep "^[a-zA-Z][^=]*='[^']*'$" |
+               grep -v '^IFS=' |
+               grep -v '^TERM' |
+               grep -v '^PPID' |
+               grep -v '^PS[1-9]=' |
+               cat)
        echo "${vars}"
        echo "${vars}" | sed -e 's!^\([a-zA-Z][^=]*\)=.*$!export \1!'
-} > bin/restore.env.source
+} >bin/restore.env.source
 
 echo "RUN: '. bin/restore.env.source'"