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

Re: zsh watch function



Han Boetes wrote on Sat, 16 May 2020 16:31 +0200:
> And then I saw the padding light, here an improved version:
> 
> watch () {
>     IN=2

The code isn't WARN_CREATE_GLOBAL-clean.

>     CM="$*"
>     LEFT="$(printf 'Every %.1f: %s' $IN $CM)"
⋮
>         printf "$LEFT%${PAD}s\n" "$HN $(date)"

$LEFT may contain unescaped percent signs from the input.

>         eval "$CM"
>         sleep $IN
>         clear
>     done
> }  

For context to others, note that watch(1) on FreeBSD does something
entirely different to what watch(1) does on Linux.



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