Sujet : Re: [ksh93u+m] alarm timer function
De : janis_papanagnou+ng (at) *nospam* hotmail.com (Janis Papanagnou)
Groupes : comp.unix.shellDate : 17. Mar 2024, 19:15:11
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <ut7bvh$3lhac$1@dont-email.me>
References : 1 2
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
On 17.03.2024 18:49, David W. Hodgins wrote:
On Sun, 17 Mar 2024 10:48:21 -0400, Janis Papanagnou
<janis_papanagnou+ng@hotmail.com> wrote:
In ksh93u+ I'm using the built-in 'alarm' timer command.
>
$ alarm --man
Usage: alarm [-r] [varname seconds]
>
(The original 'alarm' feature may have been experimental
and not documented well, but it was nonetheless useful.)
>
Just noticed in ksh93u+m that the 'alarm' timer command
doesn't seem to be available; I now get errors like
"alarm: not found"
and
timer.alarm: invalid discipline function
>
Is there some substitute in ksh93u+m that will replace
that function from the original ksh? (Or something else
to do to get it working?) Or has that feature just been
abandoned in the "u+m" branch?
I'm not a ksh user, so don't know much about it. I recommend using the
package
"at" for setting alarms and it's not shell dependent.
Thanks for the suggestion. It reminds me that I obviously
should have made the use case clear, where and how I want
to use the timer. For example; I want to display a turning
"wheel" (or maybe a growing bar) while some operation is
in progress. I might use such a timer in a program called
'busy'. And instead of calling
$ long_running_process arguments
I'd call it as
$ busy long_running_process arguments
The program 'busy' could be something like
$ cat ~/bin/busy
typeset busy='/-\|'
typeset -i i=0
alarm -r timer +0.25
function timer.alarm { print -u2 -f "%c\b" -- "${busy:i++%4:1}" ;}
( "$@" & wait )
unset timer
with 'alarm' and 'timer.alarm' used as supported by ksh93u+.
I suppose the 'at' command is not suited for such purposes.
Janis