(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
(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"))