Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Suppress print_exit_value for single function

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?



Messages sorted by: Reverse Date, Date, Thread, Author