Run commands in the background; fix quotation bug

Now running a command doesn’t block shellfox.sh,
and commands with quotes should work like normal.
This commit is contained in:
Jaidyn Ann 2024-02-28 21:57:28 -06:00
parent 9000b2a3b0
commit 55edbb1fc7

View File

@ -25,8 +25,15 @@ read_message() {
}
# Deescape a JSON stream from input.
json_deescape() {
sed 's/^"//' \
| sed 's/"$//' \
| sed 's/\"/"/g'
}
while true; do
message="$(read_message)"
command="$(echo "$message" | sed 's/^"//' | sed 's/"$//')"
"$SHELL" -c "$command"
command="$(read_message | json_deescape)"
nohup "$SHELL" -c "$command" > /dev/null &
done