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

Re: local unfunction



On 30/03/18 11:47 AM, Bart Schaefer wrote:
On Fri, Mar 30, 2018 at 9:11 AM, Ray Andrews <rayandrews@xxxxxxxxxxx> wrote:
Is it possible to unfunction something just within another function?

You can get that effect like this:

% zmodload zsh/parameter
... that's way beyond my competence Bart but I will study it. However I'm playing with Mikael's use of parenthesis -- I'd swear this is the first time I've seen any such thing -- and it seems too good to be true, so far it just works.  Are there any lurking gotchas?  Disadvantages? It doesn't seem any slower.

BTW, just to keep flogging a dead horse:

function test1 ()
{
echo  "\none"
whence -a "zsh"
echo  "\ntwo"
whence -ma "zsh*"
echo  "\nthree"
whence -m "zsh*"
}

one
/usr/local/bin/zsh
/usr/bin/zsh
/bin/zsh

two
/usr/local/bin/zsh    # Missing below
/usr/bin/zsh          # Missing below
/bin/zsh              # Missing below
/aWorking/Bin/zsh5.3  # OK, added as a wildcard match. Executable.

three
/aWorking/Zsh/System/zsh    # Missing above NOT executable, plain text.
/aWorking/Bin/zsh5.3        # Executable, why this and not the others?
/aWorking/Bin/zsh5.3:       # Missing above NOT executable, plain text.

... '-m' by itself seems very strange, but even if we presume that it is to show non-executables, it does show one of them while missing all the others.  It also missed a non executable in the current directory even tho 'dot' is on the path (if we presume it looks for non-executables but that's hardly what whence seems to be for).  '-a' and '-ma' seem to behave as one might expect.  (I have a bunch of practice targets all over the place).  '-m' seems to find executables only if globbing was needed to find them, plain vanilla 'zsh' executables are not found.  Is this really what is wanted?



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