mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-30 12:21:25 -08:00
Fix a race condition when evaluating Eshell commands
* lisp/eshell/esh-cmd.el (eshell-do-eval): Don't defer when all the processes are done. * test/lisp/eshell/esh-cmd-tests.el (esh-cmd-test/pipeline-wait/nested-pipes): New test.
This commit is contained in:
parent
91509d5d2a
commit
57dc1ed665
2 changed files with 16 additions and 2 deletions
|
|
@ -1287,13 +1287,15 @@ have been replaced by constants."
|
|||
(setcdr form (cdr new-form)))
|
||||
(eshell-do-eval form synchronous-p))
|
||||
(if-let (((memq (car form) eshell-deferrable-commands))
|
||||
(procs (eshell-make-process-list result)))
|
||||
(procs (eshell-make-process-list result))
|
||||
(active (seq-some #'eshell-process-active-p procs)))
|
||||
(if synchronous-p
|
||||
(apply #'eshell/wait procs)
|
||||
(eshell-manipulate form "inserting ignore form"
|
||||
(setcar form 'ignore)
|
||||
(setcdr form nil))
|
||||
(throw 'eshell-defer procs))
|
||||
(when active
|
||||
(throw 'eshell-defer procs)))
|
||||
(list 'quote result))))))))))))
|
||||
|
||||
;; command invocation
|
||||
|
|
|
|||
|
|
@ -213,6 +213,18 @@ This should also wait for the subcommand."
|
|||
(eshell-match-command-output "echo ${*echo hi | *cat} | *cat"
|
||||
"hi")))
|
||||
|
||||
(ert-deftest esh-cmd-test/pipeline-wait/nested-pipes ()
|
||||
"Check that piping a subcommand with its own pipe works.
|
||||
This should also wait for the subcommand."
|
||||
(skip-unless (and (executable-find "echo")
|
||||
(executable-find "cat")
|
||||
(executable-find "sh")
|
||||
(executable-find "sleep")))
|
||||
(with-temp-eshell
|
||||
(eshell-match-command-output
|
||||
"{ sh -c 'sleep 1; echo goodbye 1>&2' | *echo hello } | *cat"
|
||||
"hello\ngoodbye\n")))
|
||||
|
||||
(ert-deftest esh-cmd-test/reset-in-pipeline/subcommand ()
|
||||
"Check that subcommands reset `eshell-in-pipeline-p'."
|
||||
(skip-unless (executable-find "cat"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue