Closed herrsimon closed 2 years ago
traditionally, non-zero exit codes indicate failure of some sort and the actual number specifies the type of failure.
This is mostly true, but it can also more generally be used to indicate the reason for termination (see ping(8)).
It is no longer possible to distinguish regular exit from a true failure.
On 'real' failure warpd will terminate with 255. You can test for this like so:
warpd --normal
case $? in
0) echo "no click clack";;
1) echo "click clack!";;
255) echo "oh noes!";;
esac
There aren't too many reasons this should happen in practice.
I know no other programs which use exit codes for passing non-exit related information
I would argue the key used to exit warpd is 'exit related information'.
Wouldn't it be a better idea to print button presses together with point coordinates as a third field (empty if the exit occured without button press, as when using --hint --oneshot), resulting in ouput like 812 341 1 for mouse key 1? Shell scripts could then simply use this third field if needed.
There is no obvious solution for the print key, and I would prefer to keep things consistent.
On 'real' failure warpd will terminate with 255
Thanks, I wasn't aware of this (should have read the code properly before complaining).
I would argue the key used to exit warpd is 'exit related information'.
Actually I agree with you here and the ping example also makes your point that conveying the button pressed via exit codes has its merits.
There is no obvious solution for the print key, and I would prefer to keep things consistent.
As written in the other issue, the obvious solution would be to print the print key itself, which enables advanced scripting logic. Hence, one could think about printing btn* for the mouse buttons.
Another thing which would be interesting to know for scripts is whether the user aborted the operation by pressing an exit key. This information would be a good candidate for an error code in my opinion (this can of course only be thrown in non-daemon mode).
should have read the code properly before complaining
I probably should have documented it better. I've added a note in the man page.
As written in the other issue, the obvious solution would be to print the print key itself, which enables advanced scripting logic.
I can't think of any reason this would be useful. If you think it would allow for something which is currently not possible feel free to follow up in another issue.
Another thing which would be interesting to know for scripts is whether the user aborted the operation by pressing an exit key.
If --oneshot
is used, the exit status will be 0 if the user aborts the operation.
I'm closing this for now. Feel free to reopen it or follow up in your other threads.
I just wrote some scripts to make use of warpd's recent improvements and would like to discuss whether it is truly a good idea to indicate the pressed mouse button via exit codes. When you first introduced it, I didn't think about the consequences, but now, when writing actual scripts, extracting the mouse button from the exit code doesn't feel right. At the moment, I can only find arguments against it:
EXIT_FAILURE
and also outside of C (most notably in common linux shells) typically represents some generic errorWouldn't it be a better idea to print button presses together with point coordinates as a third field (empty if the exit occured without button press, as when using
--hint --oneshot
), resulting in ouput like812 341 1
for mouse key 1? Shell scripts could then simply use this third field if needed.If you agree to this change, I could deal with this trivial and very boring chore to take some burden off your shoulders (already feel bad since for quite some time now, all I'm doing is continually writing feature request after feature request, without contributing anything).