diff options
author | James Pannacciulli <jpnc@jpnc.info> | 2017-09-16 09:28:49 -0700 |
---|---|---|
committer | James Pannacciulli <jpnc@jpnc.info> | 2017-09-16 09:28:49 -0700 |
commit | 88643da3d30a92b7e746858ff28f050dcf08f932 (patch) | |
tree | 181bff8c7d3bcf18cc3724e9c6724da2e3bc3bda /pars.sh | |
parent | 2b5ae4104dc764bf7e254cbb02f397799ddbf957 (diff) | |
download | parssh-88643da3d30a92b7e746858ff28f050dcf08f932.tar.gz parssh-88643da3d30a92b7e746858ff28f050dcf08f932.tar.bz2 |
simplify output function, remove superfluous 3rd party util usage
Diffstat (limited to 'pars.sh')
-rw-r--r-- | pars.sh | 32 |
1 files changed, 16 insertions, 16 deletions
@@ -24,7 +24,8 @@ parssh () { local _parssh_origopts=$- set -m - local _parssh_outfun=_parssh.out + local _parssh_out_stdout=true + local _parssh_out_file=false local _parssh_prepend_host=true local _parssh_ssh=_parssh.ssh @@ -58,8 +59,9 @@ parssh () { echo "'${2}.{out,err}': unable to write / modify file" return 97 } - local _parssh_outprefix="$2" - local _parssh_outfun=_parssh.out_redirect + local _parssh_out_prefix="$2" + local _parssh_out_stdout=false + local _parssh_out_file=true shift ;; r|-rinput) @@ -84,8 +86,9 @@ parssh () { echo "'${2}.{out,err}': unable to write / modify file" return 96 } - local _parssh_outprefix="$2" - local _parssh_outfun=_parssh.out_copy + local _parssh_out_prefix="$2" + local _parssh_out_stdout=true + local _parssh_out_file=true shift ;; esac @@ -122,8 +125,8 @@ parssh () { done $_parssh_ssh "$@" 2> >(_parssh.host_prepend >&2) |\ _parssh.host_prepend & - done <&9 2> >($_parssh_outfun err >&2) - } | $_parssh_outfun out + done <&9 2> >(_parssh.out err >&2) + } | _parssh.out out wait @@ -146,17 +149,14 @@ _parssh.host_prepend () done _parssh.out () { - cat - -} - -_parssh.out_redirect () { local _parssh_out_stream="$1" - cat - > "${_parssh_outprefix}.${_parssh_out_stream}" -} -_parssh.out_copy () { - local _parssh_out_stream="$1" - tee "${_parssh_outprefix}.${_parssh_out_stream}" + while read -r; do + [[ "${_parssh_out_stdout}" == "true" ]] && \ + printf "%s\n" "$REPLY" + [[ "${_parssh_out_file}" == "true" ]] && \ + printf "%s\n" "$REPLY" >> "${_parssh_out_prefix}.${_parssh_out_stream}" + done } _parssh.usage () { |