What is the correct way to run multiple async-shell-command
invocations serially?
For example, this will execute all at once.
(progn
(async-shell-command "echo 1; sleep 1")
(async-shell-command "echo 2; sleep 1")
(async-shell-command "echo 3; sleep 1"))
But I want each command to wait for the command before it to finish first. (Of course in this case you can just chain them together with bash and &&
, but you might like to have different output buffers, etc.) And I don't want to make the user wait, which is why I don't use UI-blocking shell-command
function.
The only way I've figured out how to do this is with sentinels and continuation passing, which is very ugly.
shell-command
is no solution for you since you do not want to make the user wait for the commands to finish. If so, please give a note about that. Do you mean by "continuation" to wait for the currently running shell command with a sentinel reacting onfinished\\|exited
and start the new shell there? That is one way to go. Probablystart-process
is better for that. You could also use theasync
package and fire up allshell-command
commands synchronously in a separate Emacs with its help.