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

Re: functions -t



Bart Schaefer wrote on Wed, 13 Oct 2021 19:48 +00:00:
> On Wed, Oct 13, 2021 at 11:46 AM Pier Paolo Grassi <pierpaolog@xxxxxxxxx> wrote:
>>
>> nice, thanks!
>>
>>> % f(){}
>>> % functions -T f
>>> % which f | sed -n 2p
>>>         # traced
>
> It'd be a bit better to use  "functions f" here rather than "which",
> so that you don't end up doing a path search etc. if "f" is not a
> function.
>
> [[ $(functions -x0 f) = *$'\n# traced\n'* ]]
>
> is probably good enough.  I'm debating whether this is commonly needed
> enough that the "# traced" comment should appear in the $functions
> hash.  I suspect not.

A boolean test, perhaps?  Since «functions -T» == «typeset -f -T», how
about, say, a «typeget -f -T f» command that returns 0 or 1 according to
whether -T is/isn't set on the function f?  The idea behind this name is
that «typeset -x foo» sets -x and «typeget -x foo» would query the
setting.  For instance, «typeget -A foo» == «[[ ${(t)foo} = *assoc* ]]».

In the specific case of -T/-t, I suppose it's a fair question to ask
what «typeset -ft foo; typeget -fT foo» would return.




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