From 7190c6e330581e3f5958c601a914d87144259367 Mon Sep 17 00:00:00 2001 From: "Kay Marquardt (Gnadelwartz)" Date: Sun, 19 May 2019 17:31:55 +0200 Subject: [PATCH] fix outproc exit and show script on ps --- bashbot.sh | 7 +++++-- modules/background.sh | 8 +++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/bashbot.sh b/bashbot.sh index af65f72..8f6c2cb 100755 --- a/bashbot.sh +++ b/bashbot.sh @@ -12,7 +12,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.80-dev3-5-g83623ec +#### $$VERSION$$ v0.80-dev3-6-gbeb77a4 # # Exit Codes: # - 0 sucess (hopefully) @@ -391,6 +391,9 @@ bot_init() { local OLDTMP="${BASHBOT_VAR:-.}/tmp-bot-bash" [ -d "${OLDTMP}" ] && { mv -n "${OLDTMP}/"* "${TMPDIR}"; rmdir "${OLDTMP}"; } [ -f "modules/inline.sh" ] && rm -f "modules/inline.sh" + # shellcheck disable=SC2009 + oldbot="$(ps -ef | grep startbot | grep -v -e 'grep' -e '\-startbot' )" + [ "${oldbot}" != "" ] && echo -e "${ORANGE}Warning: Old TMUX bot is running! You must kill it manually first:${NC}\\n$${oldbot}" && exit 5 #setup bashbot [[ "${UID}" -eq "0" ]] && RUNUSER="nobody" echo -n "Enter User to run basbot [$RUNUSER]: " @@ -442,7 +445,7 @@ if [ "$1" != "source" ]; then "outproc") # forward output from interactive and jobs to chat [ "$3" = "" ] && echo "No file to read from" && exit 3 [ "$2" = "" ] && echo "No chat to send to" && exit 3 - while read -r -t 10 line ;do + while read -r line ;do [ "$line" != "" ] && send_message "$2" "$line" done rm -f -r "${TMPDIR:-.}/$3" diff --git a/modules/background.sh b/modules/background.sh index 214edf4..4cb7fd5 100644 --- a/modules/background.sh +++ b/modules/background.sh @@ -5,7 +5,7 @@ # This file is public domain in the USA and all free countries. # Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying) # -#### $$VERSION$$ v0.80-dev3-4-ge7d2eff +#### $$VERSION$$ v0.80-dev3-6-gbeb77a4 # source from commands.sh if you want ro use interactive or background jobs @@ -51,8 +51,10 @@ start_proc() { local fifo; fifo="${TMPDIR:-.}/$(procname "$1" "$3")" kill_proc "$1" "$3" mkfifo "${fifo}" - nohup bash -c "{ tail -f \"${fifo}\" | $2 \"\" \"\" \"$fifo\" | \"${SCRIPT}\" outproc \"${1}\" \"${fifo}\" - rm \"${fifo}\"; [ -s \"${fifo}.log\" ] || rm -f \"${fifo}.log\"; }" &>>"${fifo}.log" & + nohup bash &>>"${fifo}.log" <