zsh-users
 help / Atom feed
* status and pipestatus
@ 2019-07-27  6:43 Roman Perepelitsa
  2019-07-27  7:21 ` Roman Perepelitsa
  0 siblings, 1 reply; 3+ messages in thread
From: Roman Perepelitsa @ 2019-07-27  6:43 UTC (permalink / raw)
  To: Zsh Users

I'd like to use status and pipestatus special parameters in a precmd
hook. There are cases where status gets updated between two precmd
invocations but pipestatus doesn't. In such cases I don't want to use
pipestatus. In other words, I want to use pipestatus if and only if it
corresponds to the same command from which status was derived. Is this
possible?

Roman.

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

* Re: status and pipestatus
  2019-07-27  6:43 status and pipestatus Roman Perepelitsa
@ 2019-07-27  7:21 ` Roman Perepelitsa
  2019-07-31 14:36   ` Roman Perepelitsa
  0 siblings, 1 reply; 3+ messages in thread
From: Roman Perepelitsa @ 2019-07-27  7:21 UTC (permalink / raw)
  To: Zsh Users

Here are a couple of examples where I don't want to use pipestatus.

Command: false | false; x=0
State after running the command: status=0, pipestatus=(1 1)

Command: true | true; x=$(false)
State after running the command: status=1, pipestatus=(0 0)

In these two examples status comes from x=..., while pipestatus comes
from the previous pipeline.

Roman.

On Sat, Jul 27, 2019 at 8:43 AM Roman Perepelitsa
<roman.perepelitsa@gmail.com> wrote:
>
> I'd like to use status and pipestatus special parameters in a precmd
> hook. There are cases where status gets updated between two precmd
> invocations but pipestatus doesn't. In such cases I don't want to use
> pipestatus. In other words, I want to use pipestatus if and only if it
> corresponds to the same command from which status was derived. Is this
> possible?
>
> Roman.

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

* Re: status and pipestatus
  2019-07-27  7:21 ` Roman Perepelitsa
@ 2019-07-31 14:36   ` Roman Perepelitsa
  0 siblings, 0 replies; 3+ messages in thread
From: Roman Perepelitsa @ 2019-07-31 14:36 UTC (permalink / raw)
  To: Zsh Users

In case anyone with the same question finds this thread in the future,
here's how I believe status and pipestatus behave.

Every time pipestatus is updated, status is also updated. Most of the
time when status is updated, pipestatus is also updated, but there are
exceptions. In general, it's not possible to determine whether status
has been updated after the last pipestatus update but by hooking
preexec and zle-line-end it's possible to do this almost all the time.

The reason I've started digging into this is that I'm maintaining ZSH
code that shows status of the last command in the prompt. If the last
command was a pipeline, it shows status for every command in it. Or it
should. I noticed that sometimes it shows pipestatus not from the last
command and went down the rabbit hole. If you are defining your own
prompt, don't attempt to provide this feature as it doesn't seem
possible to do so reliably.

Roman.

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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-27  6:43 status and pipestatus Roman Perepelitsa
2019-07-27  7:21 ` Roman Perepelitsa
2019-07-31 14:36   ` Roman Perepelitsa

zsh-users

Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-users

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.users


AGPL code for this site: git clone https://public-inbox.org/ public-inbox