zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] FAQ update for aliasing
@ 2021-01-29 19:35 Bart Schaefer
  2021-02-01 16:13 ` Daniel Shahaf
  2022-06-12 13:10 ` Jun. T
  0 siblings, 2 replies; 10+ messages in thread
From: Bart Schaefer @ 2021-01-29 19:35 UTC (permalink / raw)
  To: Zsh hackers list

[-- Attachment #1: Type: text/plain, Size: 1110 bytes --]

The section on csh-to-zsh alias equivalence had a number of
not-incorrect but not-up-to-date references.  Attached patch fixes
these.

However, when I do "cd Etc; make FAQ" on Ubuntu 20.04.1 LTS, I get
some strange formatting.  Hopefully you can see what I mean in the
copy-paste below despite possible gmail line wrap:

--- 8< ---
Here is Bart Schaefer's guide to converting csh aliases for zsh.


  1. ) If the csh alias references "parameters" (\!:1, \!* etc.),
     then in zsh you need a function (referencing $1, $* etc.).
     In recent versions of zsh this can be done by defining an anonymous
     function within the alias.  Otherwise, a simple zsh alias suffices.

2. ) If you use a zsh function, you need to refer _at_least_ to
     $* in the body (inside the { }).  Parameters don't magically
     appear inside the { } the way they get appended to an alias.
--- 8< ---

That is, most paragraphs get a hanging left indent (outdent?), but not
all do.  This happens in other sections, not just the one touched in
the patch.  I'm not sure the hanging leader is even intentional.  Do
others see this?

[-- Attachment #2: faq-diff.txt --]
[-- Type: text/plain, Size: 1690 bytes --]

diff --git a/Etc/FAQ.yo b/Etc/FAQ.yo
index a4ffba688..7aeddd89c 100644
--- a/Etc/FAQ.yo
+++ b/Etc/FAQ.yo
@@ -715,7 +715,8 @@ label(23)
   enumeration(
   myeit() If the csh alias references "parameters" (tt(\!:1), tt(\!*) etc.),
      then in zsh you need a function (referencing tt($1), tt($*) etc.).
-     Otherwise, you can use a zsh alias.
+     In recent versions of zsh this can be done by defining an anonymous
+     function within the alias.  Otherwise, a simple zsh alias suffices.
 
   myeit() If you use a zsh function, you need to refer _at_least_ to
      tt($*) in the body (inside the tt({ })).  Parameters don't magically
@@ -759,7 +760,7 @@ label(23)
      parameters. (E.g., in a csh alias, a reference to tt(\!:5) will
      cause an error if 4 or fewer arguments are given; in a zsh
      function, tt($5) is the empty string if there are 4 or fewer
-     parameters.)
+     parameters.  Force an error in this example by using tt(${5?}).)
 
   myeit() To begin a zsh alias with a - (dash, hyphen) character, use
      mytt(alias --):
@@ -780,9 +781,8 @@ label(23)
   )
   mytt(l) in the function definition is in command position and is expanded
   as an alias, defining mytt(/bin/ls) and mytt(-F) as functions which call
-  mytt(/bin/ls), which gets a bit recursive.  This can be avoided if you use
-  mytt(function) to define a function, which doesn't expand aliases.  It is
-  possible to argue for extra warnings somewhere in this mess.
+  mytt(/bin/ls), which gets a bit recursive.  Recent versions of zsh treat
+  this as an error, but older versions silently create the functions.
 
   One workaround for this is to use the "function" keyword instead:
   verb(

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-06-14  8:38 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-29 19:35 [PATCH] FAQ update for aliasing Bart Schaefer
2021-02-01 16:13 ` Daniel Shahaf
2021-02-01 20:11   ` Bart Schaefer
2021-02-03 11:15     ` Daniel Shahaf
2022-06-12 13:10 ` Jun. T
2022-06-12 16:26   ` Bart Schaefer
2022-06-13 14:58     ` Jun. T
2022-06-13 15:04       ` Peter Stephenson
2022-06-13 17:13         ` Jun. T
2022-06-14  8:38         ` Peter Stephenson

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).