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

Re: activate alias inside subshell



On 08/04/18 01:18 PM, Bart Schaefer wrote:
On Apr 8,  7:56am, Ray Andrews wrote:
}
} Is 'zsh -f' the answer to the above -- a truly clean test of something?

The first thing asked following most bug reports is "can you reproduce
this from zsh -f?"  So yes.  Start from -f and then load the minimum
number of changes to try what you want to try (e.g., add extendedglob
if necessary, zmodload zsh/parameter or other required modules, etc.).

Thanks, I hate wasting everyone's time over really elementary issues like that.
} ... are very different!  In the former the alias is 'pending' in the
} latter, it is active, yes?  That's easy not to know.

Yes, that's correct.  "alias" is really intended only to make interactive
shells easier (reduce typing), not to abbreviate scripts (even if the
script is going to be used interactively later).

I've always distrusted any sort of macro and I use aliases only in the most limited way possible.  The anomaly is with that 'print function and line' code which seems to be impossible to put inside a function via another function except via an alias IF you want to be able to turn it on and off, thus the can of worms is opened and after that it becomes a matter more of education.  I do understand that  " ${(%):-%x %I} " is a parse time thing which is why that string can't be in a function called by another function and report anything other than its position in the immediate function, so the alias seems inevitable.   If there was such a thing as a runtime expansion of an alias, sorta an automatic 'eval',  that would be cool but I can believe that such a thing is just not on.

} BTW, results are hugely different if the redefined message function is
} redefined with or without 'function' prepended: " function msg () ... "
} vs. " msg () ... ".  Most comments found on the internet suggest there
} should be no difference

There's no difference when "msg" is not an alias.  But in
     msg() ...
the word "msg" is in command position and therefore subject to alias
expansion, whereas in
     function msg () ...
it is *not* in command position and will not be alias-expanded.

Ah!!  Nuts ... I'm unconsciously thinking that a function definition is somehow immune to alias substitution.  Why would it be?  And yes, the 'command position' thing is easy to forget about.  I know it in theory but in practice ...

Ok, I'll bet that's everything I need to understand my issue.




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