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

Re: symlink chain.



On 01/02/2015 11:17 PM, Bart Schaefer wrote:
torch% /foo() { print Look, I have a slash. }
torch% whence -v /foo
/foo is a shell function
torch% whence -mv '/fo?'	# won't work with the above change
/foo is a shell function

PWS's change for -a only works because it happens so late in the algorithm
that there is nothing left but path to search, and no patterns left to be
tried.

As you say. The test for the leading slash is obviously a bit of a band-aid. I'd have expected the -m and/or -a code to be able to look at a full path without that being any sort of problem--it wouldn't have any work to do so it would get the day off, but neither would it force a false negative return (rather the way that -s just does nothing when it has nothing to do, but it doesn't break anything, either).

All I can say with conviction is that 'whence -m /usr/bin/zsh' should not return nothing, because the file exists on the path and is a link to an executable and has a legitimate search target string. It should be found. It is pathetic that if I was doing a whole list of whences with the -m or -a switches, and then at some point I entered a canonical filename (whereas up to that point it was more the pattern search thing), I get nothing because, oops, I forgot to remove the -m and/or -a. Or this alias:

    alias wenceslas='whence -mavs'

... doesn't work with a canonical filename :(

Whence is a wrench. Wrenches should not be hard to understand and they shouldn't have any gotchas. It should take two minutes to know how whence works and it should work every time in an intuitive way. No switch should break anything. To be theatrical, I think if zsh made wrenches, they would only tighten metric nuts on Tuesdays and they would only loosen fractional nuts on long weekends *but* you could lay a zsh wrench on top of your engine and it would do a full valve job for you and do it right (except on Fridays). Pardon ;-)

BTW, for what it's worth, in one of my wrappers I do this:

   find_count=`whence -ma "$1" | wc -l`

... I'm just using whence at that point to search for and count targets which then are given the 3d degree:

   $ i ,v zsh

   Current path:

   /aWorking/Bin
   /usr/local/bin
   /usr/sbin
   /usr/bin
   /sbin
   /bin

   Aliases, Functions, Builtins, Scripts or Binaries: Found 3 matches:

   (1)TYPE: zsh is /usr/local/bin/zsh ->
   /usr/local/bin/zsh-5.0.7-165-g2194da1:
   LISTING: lrwxrwxrwx 1 22 2014-12-30-19:59:18 /usr/local/bin/zsh ->
   zsh-5.0.7-165-g2194da1*
   LINK CHAIN:
   l zsh -> zsh-5.0.7-165-g2194da1
   CONTENT: inode/symlink; charset=binary

   (2)TYPE: zsh is /usr/bin/zsh -> /usr/local/bin/zsh-5.0.7-165-g2194da1:
   LISTING: lrwxrwxrwx 1 28 2014-02-09-19:29:52 /usr/bin/zsh ->
   /etc/alternatives/zsh-usrbin*
   LINK CHAIN:
   l zsh -> /etc/alternatives/zsh-usrbin
   l   zsh-usrbin -> /usr/local/bin/zsh
   l     zsh -> zsh-5.0.7-165-g2194da1
   CONTENT: inode/symlink; charset=binary

   (3)TYPE: zsh is /bin/zsh -> /usr/local/bin/zsh-5.0.7-165-g2194da1:
   LISTING: lrwxrwxrwx 1 21 2014-02-09-19:29:52 /bin/zsh ->
   /etc/alternatives/zsh*
   LINK CHAIN:
   l zsh -> /etc/alternatives/zsh
   l   zsh -> /usr/local/bin/zsh
   l     zsh -> zsh-5.0.7-165-g2194da1
   CONTENT: inode/symlink; charset=binary

... and sometimes I want to give the 3d degree to a single specified file:


    $ i ,v /usr/bin/zsh

... and that's when it bugs me that the 'whence -ma' test fails. I can work around it, but I shouldn't hafta. -m and -a should be smart enough to handle a canonical filename.

(BTW The above is my idea of one-stop shopping for information about a command ;-)



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