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

Re: dynamic named directories clobber $reply



On Jun 4,  2:24pm, Mikael Magnusson wrote:
} Subject: dynamic named directories clobber $reply
}
} I noticed that after a successful ~[something] substitution, ~[] or
} ~[invalid] would return the same substitution, because $reply leaks to
} the parent shell, and my function doesn't unset $reply when it doesn't
} find anything valid. If I make it local in the function it doesn't
} work at all, is there some way it can be local in the hook somehow?

I'd say the short answer to that is "no".  Nothing else that uses
reply/REPLY internally to the shell invokes any kind of local context
for them.

However, the hook conceivably could explicitly unset reply before the
call to the shell function.  This would have to happen in Src/utils.c
subst_string_by_hook(), and presumably only if a function or variable
named zsh_directory_name was actually found.

I'm undecided whether that's the correct thing to do, or whether it
really should be up to the shell function to make sure reply is correct
regardless of whether it found a match or not.  It's unclear because in
the case of an array of zsh_directory_name_hook functions, you may not
want each to go clobbering the results of the one before.



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