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

Re: time command with shell builtins



On Thu, Jan 26, 2023 at 8:23 AM Dominik Vogt <dominik.vogt@xxxxxx> wrote:
>
> Is there a more elegant way to chek if the command is in a
> blacklist than this one?
>
>   if [[ -z "${1:|_zsh_recordtime_skip_list}" ]]; then

Alternate methods, judgement on elegance reserved:

if (( ${_zsh_recordtime_skip_list[(Ie)$1]} )); then

Or maintain _zsh_recordtime_skip_list as an associative array and

if (( ${+_zsh_recordtime_skip_list[$1]} )); then

In that case you could further use patterns as the keys of the array and do

if [[ -z ${_zsh_recordtime_skip_list[(k)$1]} ]]; then

or even use a zsh/db/gdbm ztie'd hash so that new items could be added
to the list and potentially shared among shells.

Note that ${+assocarray[(k)pat]} or [(I)pat] always returns 1 even
when no matching elements exist (that is, the result is empty string
rather than unset).  I'm not sure whether that should be considered a
bug, but it's not explicitly documented.




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