zsh-users
 help / color / mirror / code / Atom feed
From: Ray Andrews <rayandrews@eastlink.ca>
To: zsh-users@zsh.org
Subject: Re: activate alias inside subshell
Date: Sun, 8 Apr 2018 13:54:29 -0700	[thread overview]
Message-ID: <4ad264be-0d8f-e50e-e664-f6d118182caf@eastlink.ca> (raw)
In-Reply-To: <180408131814.ZM7928@torch.brasslantern.com>

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.



  reply	other threads:[~2018-04-08 20:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-04-06 16:29 Ray Andrews
2018-04-07 19:57 ` Ray Andrews
2018-04-08  7:39   ` Bart Schaefer
2018-04-08 14:56     ` Ray Andrews
2018-04-08 20:18       ` Bart Schaefer
2018-04-08 20:54         ` Ray Andrews [this message]
2018-04-08 22:38       ` Ray Andrews
2018-04-09  4:11         ` Ray Andrews

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4ad264be-0d8f-e50e-e664-f6d118182caf@eastlink.ca \
    --to=rayandrews@eastlink.ca \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).