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:
parent
9000b2a3b0
commit
55edbb1fc7
13
shellfox.sh
13
shellfox.sh
|
@ -25,8 +25,15 @@ read_message() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Deescape a JSON stream from input.
|
||||||
|
json_deescape() {
|
||||||
|
sed 's/^"//' \
|
||||||
|
| sed 's/"$//' \
|
||||||
|
| sed 's/\"/"/g'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
message="$(read_message)"
|
command="$(read_message | json_deescape)"
|
||||||
command="$(echo "$message" | sed 's/^"//' | sed 's/"$//')"
|
nohup "$SHELL" -c "$command" > /dev/null &
|
||||||
"$SHELL" -c "$command"
|
|
||||||
done
|
done
|
||||||
|
|
Ŝarĝante…
Reference in New Issue