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

Re: whence (was Re: local unfunction)



On 31/03/18 08:25 AM, Bart Schaefer wrote:
% whence -wm "zsh*"

$ whence -wm "zsh*"
zsh: command
zsh5.3: command        # binary
zsh5.3:: command        # text file

... I've yet to understand what the point of the '-w' switch is. I dunno Bart, it seems I'm the only guy who has issues with whence so perhaps I shouldn't belabour all this but it seems riddled with bugs to me. '-m' and '-a' seem to fight each other and the results are inconclusive.  whence is important, one needs to know what is going to be executed when one types a command, these ifs and buts are frustrating.  My wrapper around whence is approaching 300 lines, and it's only purpose is to give one-stop shopping for what, it seems to me, whence should do anyway:

-a # keep looking after the first match (the one to be executed) is found

-m # find all matches of a pattern, subsumes '-a'  (executable ONLY unless ... )

-t # Show non executable (text?) files as well, obviates -a, subsumes 'm'.

-s, -S  # Expand links, even if found on 'dot' on the path.

So: 'whence -mts "zsh*" ' ... would give me one stop shopping for anything that is either directly executable or sourcable via path search (which zsh does anyway).  '-a' is actually redundant:

$ whenz zsh # Command that will be executed.

$ whenz -m zsh # Keep searching. (no pattern but so what, keep searching anyway.)

$ whenz -m "zsh*" # Keep searching and match the pattern too (because one is given).

$ whenz -mt "zsh*" # As above, but match non executables on the path as well.

$ whenz -mtS "zsh*" As above but show link chains, even on the 'dot', even on Tuesdays.

Logical?



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