mirror of
https://github.com/octoleo/telegram-bot-bash.git
synced 2024-12-29 05:02:46 +00:00
optimize job_control
This commit is contained in:
parent
fd7ca77cc1
commit
8669cfb785
@ -5,7 +5,7 @@
|
|||||||
# This file is public domain in the USA and all free countries.
|
# This file is public domain in the USA and all free countries.
|
||||||
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
# Elsewhere, consider it to be WTFPLv2. (wtfpl.net/txt/copying)
|
||||||
#
|
#
|
||||||
#### $$VERSION$$ v0.80-pre-9-g8dfdf2e
|
#### $$VERSION$$ v0.80-pre-10-gfd7ca77
|
||||||
|
|
||||||
# source from commands.sh if you want ro use interactive or background jobs
|
# source from commands.sh if you want ro use interactive or background jobs
|
||||||
|
|
||||||
@ -112,10 +112,7 @@ inproc() {
|
|||||||
job_control() {
|
job_control() {
|
||||||
local content proc CHAT job fifo
|
local content proc CHAT job fifo
|
||||||
for FILE in "${TMPDIR:-.}/"*-back.cmd; do
|
for FILE in "${TMPDIR:-.}/"*-back.cmd; do
|
||||||
if [ "${FILE}" = "${TMPDIR:-.}/*-back.cmd" ]; then
|
[ "${FILE}" = "${TMPDIR:-.}/*-back.cmd" ] && echo -e "${RED}No background processes.${NC}" && break
|
||||||
echo -e "${RED}No background processes.${NC}"
|
|
||||||
break
|
|
||||||
else
|
|
||||||
content="$(< "${FILE}")"
|
content="$(< "${FILE}")"
|
||||||
CHAT="${content%%:*}"
|
CHAT="${content%%:*}"
|
||||||
job="${content#*:}"
|
job="${content#*:}"
|
||||||
@ -130,17 +127,12 @@ job_control() {
|
|||||||
"suspendb"*)
|
"suspendb"*)
|
||||||
echo "Suspend Job: ${proc} ${fifo}"
|
echo "Suspend Job: ${proc} ${fifo}"
|
||||||
kill_proc "${CHAT}" "${proc}" "${job}"
|
kill_proc "${CHAT}" "${proc}" "${job}"
|
||||||
rm -f "${TMPDIR:-.}/${fifo}"
|
|
||||||
[ -s "${TMPDIR:-.}/${fifo}.log" ] || rm -f "${TMPDIR:-.}/${fifo}.log"
|
|
||||||
;;
|
;;
|
||||||
"killb"*)
|
"killb"*)
|
||||||
echo "Kill Job: ${proc} ${fifo}"
|
echo "Kill Job: ${proc} ${fifo}"
|
||||||
kill_proc "${CHAT}" "${proc}" "${job}"
|
kill_proc "${CHAT}" "${proc}" "${job}"
|
||||||
rm -f "${FILE}" # remove job
|
rm -f "${FILE}" # remove job
|
||||||
rm -f "${TMPDIR:-.}/${fifo}"
|
|
||||||
[ -s "${TMPDIR:-.}/${fifo}.log" ] || rm -f "${TMPDIR:-.}/${fifo}.log"
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user