aboutsummaryrefslogtreecommitdiffstats
path: root/pars.sh
diff options
context:
space:
mode:
authorJames Pannacciulli <jpnc@jpnc.info>2017-09-16 09:28:49 -0700
committerJames Pannacciulli <jpnc@jpnc.info>2017-09-16 09:28:49 -0700
commit88643da3d30a92b7e746858ff28f050dcf08f932 (patch)
tree181bff8c7d3bcf18cc3724e9c6724da2e3bc3bda /pars.sh
parent2b5ae4104dc764bf7e254cbb02f397799ddbf957 (diff)
downloadparssh-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.sh32
1 files changed, 16 insertions, 16 deletions
diff --git a/pars.sh b/pars.sh
index 91b1022..670a552 100644
--- a/pars.sh
+++ b/pars.sh
@@ -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 () {