summaryrefslogtreecommitdiff
path: root/ctdb/tools
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2017-08-09 17:11:18 +1000
committerAmitay Isaacs <amitay@samba.org>2017-08-14 05:15:25 +0200
commit4dc41cd2b636030e21991685788480a0ea0cdaa1 (patch)
tree85cdc4d3ed02e6e929708796f2b58356e0834907 /ctdb/tools
parent3654694a092b15733bd04631786e60627c392c6a (diff)
downloadsamba-4dc41cd2b636030e21991685788480a0ea0cdaa1.tar.gz
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 <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb/tools')
-rwxr-xr-xctdb/tools/onnode23
1 files changed, 21 insertions, 2 deletions
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