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

Re: 'whence' anomaly.



On 03/24/2014 03:48 PM, Bart Schaefer wrote:
On Mar 24, 11:19am, Ray Andrews wrote:
}
} What causes this:
}
} >     $ whence -m mplayer
} >
} >     $ whence mplayer
} >     /usr/bin/mplayer
} >
} >     $ whence -m mplayer
} >     /usr/bin/mplayer

I guess you could think of it as both/either a bug and/or a feature ...

"whence -m" searches, but does not populate, the command hash table.
Thus if the NO_HASH_CMDS option is set, "whence -m" does not work
at all. [*]

"whence" populates the hash table as a side-effect of searching $PATH,
presuming HASH_CMDS is set; but it might not fully populate the table
if HASH_DIRS is set, so "whence -m" of a different command from later
in the $PATH might still fail.

[*] Except that the CORRECT option also relies on the hash table, so
if that is set, as soon as anything might need correcting, the table
gets filled, and "whence -m" will start working again.

Yikes, more ifs buts and maybes. Is there some way to get a reliable result? AFAICT, none of the options you mention are set here (that's from scanning the output of " $ set "). Should I always make a
double call?: " $ whence mplayer; whence -m "mplayer" ? Set some option?



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