Re: [dev] New utility "when"
Samuel Holland <samuel_AT_sholland.net> wrote:
>>> On Dec 12, 2013, at 4:10 PM, "Fernando C.V." <ferkiwi_AT_gmail.com>
>wrote:
>>> On Thu, Dec 12, 2013 at 10:49 PM, Fernando C.V. <ferkiwi_AT_gmail.com>
>wrote:
>>> This way could do something like:
>>>
>>> $ when -t ssh host
>>>> xmessage DONE!
>>
>> Well... even if you didn't prompt it to the user interactively, it
>> would still be nice for aliases.
>> Probably most of the time you just want to get notfications:
>>
>> $ alias retry='echo "xmessage DONE" | when'
>> $ retry ssh host
>
>And if you only need simple messages, then there's nothing wrong with
>having to quote the "on success" command:
>
>$ when -t -c "xmessage Success" <command> <args...>
>
>The advantage of specifying the message command as an argument (as
>opposed to &&) is that it allows you to pass through the return value
>of the main command. For example, if your long-running program is still
>running after the timeout, you get the message; but it may fail later,
>and you want to know about that too.
>
>$ when -t -c 'logger "Service started successfully"'
>non-forking-service || logger "Service exited unexpectedly"
-t already does this.
I think I'm going to drop support for running the on success command in favor of letting the shell do it. I'll then modify the way -t gets its success command. Copy argv until -alert (or some other special switch) for the first command, then copy the rest for the alerting command. In this way, you get the ability to specify both commands without quotes in the general case, and it's as bit more clear what is going on. It also eliminates the need to specify -t. Thoughts?
I also like the idea of renaming this to retry (suggested by someone on this list), as it better captures the usage.
Received on Fri Dec 13 2013 - 14:25:41 CET
This archive was generated by hypermail 2.3.0
: Fri Dec 13 2013 - 14:36:06 CET