From f55571306ae99ca64910fa64276e1b6da308b792 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Mon, 8 Apr 2019 12:40:07 +0200 Subject: [PATCH] use while loop for broadcast --- bashbot.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bashbot.sh b/bashbot.sh index d78960c..ff4fb83 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -538,13 +538,14 @@ case "$1" in rm -f -r "${TMPDIR:-.}/$3" ;; "count") - echo "A total of $(wc -l "${COUNT}" | sed 's/count//g')users used me." + echo "A total of $(wc -l <"${COUNT}") users used me." ;; "broadcast") - echo "Sending the broadcast $* to $(wc -l "${COUNT}" | sed 's/count//g')users." - [ "$(wc -l "${COUNT}" | sed 's/ count//g')" -gt "300" ] && sleep="sleep 0.5" + NUMCOUNT="$(wc -l <"${COUNT}")" + echo "Sending the broadcast $* to $NUMCOUNT users." + [ "$NUMCOUNT" -gt "300" ] && sleep="sleep 0.5" shift - for f in $(cat "${COUNT}"); do send_message "${f//COUNT}" "$*"; $sleep;done + while read -r f; do send_message "${f//COUNT}" "$*"; $sleep; done <"${COUNT}" ;; "start") $CLEAR