Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH] Let run-help try to show function source from file (was Re: [RFC][PATCH] Try calling command with help flags in run-help)
- X-seq: zsh-workers 48990
- From: Marlon Richert <marlon.richert@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: [PATCH] Let run-help try to show function source from file (was Re: [RFC][PATCH] Try calling command with help flags in run-help)
- Date: Wed, 2 Jun 2021 21:26:48 +0300
- Archived-at: <https://zsh.org/workers/48990>
- In-reply-to: <CAH+w=7Y1M-TkTJNb0q8LECy6-fViN=As5cn6KohneyeDLdPv4Q@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAHLkEDsDG7X9+oN8AowUoqcPU731tHALXJGvaqkxV8XnR2kULg@mail.gmail.com> <CAH+w=7Y1M-TkTJNb0q8LECy6-fViN=As5cn6KohneyeDLdPv4Q@mail.gmail.com>
Here's part of workers 48926 as a separate patch.
On Tue, May 25, 2021 at 11:57 PM Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> On Tue, May 25, 2021 at 1:49 PM Marlon Richert <marlon.richert@xxxxxxxxx> wrote:
> >
> > When there isn't a man page, try calling the command with --help or -h.
>
> This is not a good idea, because we can't predict what will happen if
> a given command does not support those options, or interprets them
> differently.
From 4cbb4642bb9c4f06fbc6729ecf2995e498cf3d61 Mon Sep 17 00:00:00 2001
From: Marlon Richert <marlon.richert@xxxxxxxxx>
Date: Wed, 2 Jun 2021 21:22:59 +0300
Subject: [PATCH] Let run-help try to show function source from file
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
…because parsed functions don't contain comments.
---
Functions/Misc/run-help | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/Functions/Misc/run-help b/Functions/Misc/run-help
index e351dd6a6..b5e692198 100644
--- a/Functions/Misc/run-help
+++ b/Functions/Misc/run-help
@@ -69,7 +69,18 @@ do
(comp*) man zshcompsys;;
(zf*) man zshftpsys;;
(run-help) man zshcontrib;;
- (*) builtin functions ${what[(w)1]} | ${=PAGER:-more};;
+ ( * )
+ local func=$what[(w)1]
+
+ # Try to show function source from file, because parsed functions
+ # don't contain comments.
+ autoload +X -Uz $func
+ if [[ -n $functions_source[$func] ]]; then
+ ${=PAGER:-more} -- $functions_source[$func]
+ else
+ builtin functions $func | ${=PAGER:-more}
+ fi
+ ;;
esac;;
(*( is a * builtin))
case ${what[(w)1]} in
--
2.30.1 (Apple Git-130)
Messages sorted by:
Reverse Date,
Date,
Thread,
Author