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

Re: Alias call in function fails...



Perry Smith wrote on Tue, 23 Jun 2020 16:14 -0500:
> > On Jun 23, 2020, at 11:03 AM, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx <mailto:schaefer@xxxxxxxxxxxxxxxx>> wrote:
> > 
> > The other thing is make replacements in contexts other than the
> > "command  position" (global aliases).  
> 
> I’d really appreciate if you could give a few examples of this.
> 

[[[
diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index ada69c99a..bff5c4a18 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -105,7 +105,16 @@ For each var(name) with a corresponding var(value), define an alias
 with that value.  A trailing space in var(value) causes the next word
 to be checked for alias expansion.  If the tt(-g) flag is present,
 define a global alias; global aliases are expanded even if they do not
-occur in command position.
+occur in command position:
+
+example(% print -rC1 foo bar ANNOTATE
+foo
+bar
+ANNOTATE
+% alias -g ANNOTATE='| nl -ba'
+% print -rC1 foo bar ANNOTATE
+     1  foo
+     2  bar)
 
 If the tt(-s) flag is present, define a suffix alias: if the command
 word on a command line is in the form `var(text)tt(.)var(name)', where
]]]

Is this sufficiently clear to be committed?  There's already a
noderef(Aliasing) a few paragraphs below, which explains how aliases
are expanded before almost all other parsing (which is why the «|» on
the RHS works), but it's perhaps not self-explanatory that nl(1) is an
external command.



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