From: Martin Schwenke Date: Wed, 9 Aug 2017 07:11:18 +0000 (+1000) Subject: ctdb-tools: Reformat and explain complex code X-Git-Tag: tdb-1.3.15~106 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4dc41cd2b636030e21991685788480a0ea0cdaa1;p=thirdparty%2Fsamba.git ctdb-tools: Reformat and explain complex code There are multiple command groups and redirects on very long lines. Reformat the long lines to break them up and add a comment to explain what is happening. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/tools/onnode b/ctdb/tools/onnode index b3efe91c85b..8da40d2bd21 100755 --- a/ctdb/tools/onnode +++ b/ctdb/tools/onnode @@ -359,15 +359,34 @@ trap 'kill -TERM $pids 2>/dev/null' INT TERM retcode=0 for n in $nodes ; do set -o pipefail 2>/dev/null + + # The following code applies stdout_filter and stderr_filter to + # the relevant streams. Both filters are at the end of pipes so + # they read from stdin and (by default) write to stdout. To allow + # the filters to operate independently, the output of + # stdout_filter is sent to a temporary file descriptor (3), which + # is redirected back to stdout at the outermost level. if $parallel ; then - { exec 3>&1 ; { $SSH $ssh_opts $EXTRA_SSH_OPTS "$n" "$command" | stdout_filter >&3 ; } 2>&1 | stderr_filter ; } & + { + exec 3>&1 + { + $SSH $ssh_opts $EXTRA_SSH_OPTS "$n" "$command" | + stdout_filter >&3 + } 2>&1 | stderr_filter + } & pids="${pids} $!" else if $verbose ; then echo >&2 ; echo ">> NODE: $n <<" >&2 fi - { exec 3>&1 ; { $SSH $ssh_opts $EXTRA_SSH_OPTS "$n" "$command" | stdout_filter >&3 ; } 2>&1 | stderr_filter ; } + { + exec 3>&1 + { + $SSH $ssh_opts $EXTRA_SSH_OPTS "$n" "$command" | + stdout_filter >&3 + } 2>&1 | stderr_filter + } [ $? = 0 ] || retcode=$? fi done