zsh-workers
 help / color / mirror / code / Atom feed
* Get exit code of a command run via coproc {cmd}?
@ 2023-05-09  9:45 Sebastian Gniazdowski
  2023-05-09 17:08 ` Bart Schaefer
  0 siblings, 1 reply; 2+ messages in thread
From: Sebastian Gniazdowski @ 2023-05-09  9:45 UTC (permalink / raw)
  To: Zsh hackers list

Hi
I'm running a command in coproc:
coproc {ls -1 dir;}

I would like to know if the ls succeeded (could fail if e.g.: no
`dir`).. How to accomplish this task? $jobstates doesn't hold exit
code and is cleared immediately when ls ends with no chance to read
it.

-- 
Best regards,
Sebastian Gniazdowski


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Get exit code of a command run via coproc {cmd}?
  2023-05-09  9:45 Get exit code of a command run via coproc {cmd}? Sebastian Gniazdowski
@ 2023-05-09 17:08 ` Bart Schaefer
  0 siblings, 0 replies; 2+ messages in thread
From: Bart Schaefer @ 2023-05-09 17:08 UTC (permalink / raw)
  To: Sebastian Gniazdowski; +Cc: Zsh hackers list

On Tue, May 9, 2023 at 2:46 AM Sebastian Gniazdowski
<sgniazdowski@gmail.com> wrote:
>
> I'm running a command in coproc:
> I would like to know if the [coproc] succeeded

The value of $! immediately after starting the coproc is its process
ID, just like any other background job.
  coproc ...
  coproc_pid=$!
  ...
  wait $coproc_pid
will give you the exit status, modulo the caveats explained under the
"wait" description.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-05-09 17:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-09  9:45 Get exit code of a command run via coproc {cmd}? Sebastian Gniazdowski
2023-05-09 17:08 ` Bart Schaefer

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).