Closed paride closed 7 years ago
First of all, thanks for your time and interest.
I like very much the idea to make snore behave like a stopwatch when no arguments are given, that's why I somewhat thought to already have done that by making it sleeping for 24h. I think that 1d is far much more than anyone may wants by a stopwatch.
Your patch is fine but I would consider to set some upper limit (DBL_MAX?) which we have to address anyway (due to the SIGSEGV you noticed) and just do something like:
if(!endtm)
endtm = upper_limit_value;
This keep things as simple as possible. Let's see if someone else share his/her thoughts. I've just merged your commit on indentation.
I get you point and it does make sense.
I wonder what (coreutils) sleep
does, as it doesn't seem to have a hard limit on the sleep time.
What about sleep[0] from sbase? It just prints an error and exits[1] which is the simplest solution. I gave a look at sleep[2] from coreutils. It loops until there is no more time left or ERANGE is returned which sounds reasonable and also solve the overflow problem. I just wonder if this feature is worth the additional complexity.
[0] http://git.suckless.org/sbase/tree/sleep.c [1] http://git.suckless.org/sbase/tree/libutil/strtonum.c#n77 [2] http://git.savannah.gnu.org/cgit/coreutils.git/tree/src/sleep.c
Here I suggest to change the default behavior of
snore
when no arguments are given. Instead of sleeping for 24h, just act as a stopwatch, to be stopped with^C
.I didn't update the manpage, as I'd like to have an opinion on this change before any further work.