diff options
author | Martin Schwenke <martin@meltin.net> | 2017-08-09 17:11:18 +1000 |
---|---|---|
committer | Amitay Isaacs <amitay@samba.org> | 2017-08-14 05:15:25 +0200 |
commit | 4dc41cd2b636030e21991685788480a0ea0cdaa1 (patch) | |
tree | 85cdc4d3ed02e6e929708796f2b58356e0834907 /ctdb/tools/onnode | |
parent | 3654694a092b15733bd04631786e60627c392c6a (diff) | |
download | samba-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/onnode')
-rwxr-xr-x | ctdb/tools/onnode | 23 |
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 |