zsh-users
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: Suppress print_exit_value for single function
Date: Sat, 5 May 2018 15:10:54 +0000	[thread overview]
Message-ID: <20180505151054.k4iwezfirs3uemsk@tarpaulin.shahaf.local2> (raw)
In-Reply-To: <CAKc7PVBUGJqa19ix_qwDE+mtvTwYfZPfQ4LPNfUT67jGtFZx7w@mail.gmail.com>

Sebastian Gniazdowski wrote on Sun, Apr 29, 2018 at 20:42:43 +0200:
> Hello,
> in a 1-second sched function, I do:
> 

Thanks for including the example code downthread.

> __ret=$?
> ...
> return $__ret
> 
> This solves $? malforming by background task. However, for `setopt
> print_exit_value', this leads to constant "zsh: Exit 1" message, every
> second.
> 

I'm not sure that this is a problem.  The user opted in to being notified of
errors; there was an error; it was notified of.  If anything, isn't the bug
here that the diagnostic, "zsh: exit 1", neglects to specify the name of the
function that returned that value?

> Can I block `setopt print_exit_value' effects for this sched function or to
> all sched functions in general? I think a feature could be added for this,
> it looks very reasonable and useful.

The answer ought to be "If you don't want sched functions to result in stderr
spam, have your sched functions return zero.", except it sounds like doing that
will override the $? variable of the main shell, creating a race condition:

% echo start && make && echo end
[at 12:00] start
[go have some coffee]
[at 12:03] a 'sched' function returns non-zero
[at 12:05] 'make' finishes successfully, but "end" doesn't get printed

(Right?  I haven't tested this, I'm just going by your description)

So, isn't the answer to that to teach the C code not to write the return value
of a sched function to the global value of $? — but to keep printing
printexitvalue warnings for sched functions?

Cheers,

Daniel


  parent reply	other threads:[~2018-05-05 15:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-29 18:42 Sebastian Gniazdowski
2018-04-29 19:02 ` Bart Schaefer
2018-04-30  2:21   ` Sebastian Gniazdowski
2018-04-30  2:23     ` Sebastian Gniazdowski
2018-05-04 16:29   ` Sebastian Gniazdowski
2018-05-05 15:10 ` Daniel Shahaf [this message]
2018-05-05 16:11   ` Sebastian Gniazdowski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180505151054.k4iwezfirs3uemsk@tarpaulin.shahaf.local2 \
    --to=d.s@daniel.shahaf.name \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).