From 554605ee04946160e360354c4aee9102c877ac19 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Fri, 4 Jul 2003 16:27:36 +0000 Subject: 18810: Various enhancements and bug fixes for the TCP function suite --- Functions/TCP/tcp_spam | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'Functions/TCP/tcp_spam') diff --git a/Functions/TCP/tcp_spam b/Functions/TCP/tcp_spam index 8b84cd0d2..345be7f21 100644 --- a/Functions/TCP/tcp_spam +++ b/Functions/TCP/tcp_spam @@ -4,6 +4,8 @@ # If not given and tcp_spam_list is set to a list of sessions, # only those will be spammed. If tcp_no_spam_list is set, those # will (also) be excluded from spamming. +# -e use `eval' to run the command list instead of executing as +# a normal command line. # -l sess1,sess2 give comma separated list of sessions to spam # -r reverse, spam in opposite order (default is alphabetic, -r means # omegapsiic). Note tcp_spam_list is not sorted (but may be reversed). @@ -19,14 +21,17 @@ emulate -L zsh setopt extendedglob -local TCP_SESS cmd opt verbose reverse sesslist transmit all +local cursess=$TCP_SESS sessstr +local TCP_SESS cmd opt verbose reverse sesslist transmit all eval local match mbegin mend REPLY local -a sessions -while getopts "al:rtv" opt; do +while getopts "ael:rtv" opt; do case $opt in (a) all=1 ;; + (e) eval=1 + ;; (l) sessions+=(${(s.,.)OPTARG}) ;; (r) reverse=1 @@ -82,7 +87,7 @@ fi if [[ -n $transmit ]]; then cmd=tcp_send -else +elif [[ -z $eval ]]; then cmd=$1 shift fi @@ -95,7 +100,18 @@ for TCP_SESS in $sessions; do tcp_on_spam $TCP_SESS $cmd $* [[ $REPLY = done ]] && continue fi - [[ -n $verbose ]] && zformat -f REPLY $TCP_PROMPT "s:$TCP_SESS" \ - "f:${tcp_by_name[$TCP_SESS]}" && print -r $REPLY - eval $cmd '$*' + if [[ -n $verbose ]]; then + if [[ $TCP_SESS = $cursess ]]; then + sessstr="c:1" + else + sessstr="c:0" + fi + zformat -f REPLY $TCP_PROMPT "s:$TCP_SESS" \ + "f:${tcp_by_name[$TCP_SESS]}" $sessstr && print -r $REPLY + fi + if [[ -n $eval ]]; then + eval $* + else + eval $cmd '$*' + fi done -- cgit 1.4.1