Hi, both patches are also available through my repository https://github.com/jo-so/zsh.git ==================== run-help: Support variables in aliases If the alias definition starts with a variable assignment, run-help fails, because it sees the variable assignment as command. Hence, skip all variable assignments and noglob|nocorrect thereafter. Example: % alias T='LC_ALL=C true' % run-help T ==================== run-help-git: Print alias and skip shell commands Print the definition of the git-alias like run-help does for shell aliases. Git handles an alias starting with ! as a shell command. Hence, there's no man-page for it. Bye, Jörg
From a184bff4e75445150ce75e7e273bd7bc1b0d273c Mon Sep 17 00:00:00 2001
Message-Id: <a184bff4e75445150ce75e7e273bd7bc1b0d273c.1494259970.git.joerg@xxxxxxxxxxxx>
From: =?UTF-8?q?J=C3=B6rg=20Sommer?= <joerg@xxxxxxxxxxxx>
Date: Mon, 8 May 2017 17:46:52 +0200
Subject: [PATCH 1/2] run-help: Support variables in aliases
If the alias definition starts with a variable assignment, run-help fails,
because it sees the variable assignment as command. Hence, skip all
variable assignments and noglob|nocorrect thereafter.
Example:
% alias T='LC_ALL=C true'
% run-help T
---
Functions/Misc/run-help | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/Functions/Misc/run-help b/Functions/Misc/run-help
index e351dd6a6..4df689192 100644
--- a/Functions/Misc/run-help
+++ b/Functions/Misc/run-help
@@ -56,13 +56,16 @@ do
[[ -n $noalias && $what = *" is an alias "* ]] && continue
builtin print -r $what
case $what in
- (*( is an alias for (noglob|nocorrect))*)
- [[ ${what[(w)7]:t} != ${what[(w)1]} ]] &&
- run_help_orig_cmd=${what[(w)1]} run-help ${what[(w)7]:t}
- ;;
(*( is an alias)*)
- [[ ${what[(w)6]:t} != ${what[(w)1]} ]] &&
- run_help_orig_cmd=${what[(w)1]} run-help ${what[(w)6]:t}
+ local cmd_idx=6
+ while [[ ${what[(w)$cmd_idx]} == *=* ]]
+ do
+ (( ++cmd_idx ))
+ done
+ [[ ${what[(w)$cmd_idx]} == (noglob|nocorrect) ]] &&
+ (( ++cmd_idx ))
+ [[ ${what[(w)$cmd_idx]:t} != ${what[(w)1]} ]] &&
+ run_help_orig_cmd=${what[(w)1]} run-help ${what[(w)$cmd_idx]:t}
;;
(*( is a * function))
case ${what[(w)1]} in
--
2.11.0
From fe825e405b5bd9358718c2e5f1b0ba20b7d7cb9a Mon Sep 17 00:00:00 2001
Message-Id: <fe825e405b5bd9358718c2e5f1b0ba20b7d7cb9a.1494259970.git.joerg@xxxxxxxxxxxx>
In-Reply-To: <a184bff4e75445150ce75e7e273bd7bc1b0d273c.1494259970.git.joerg@xxxxxxxxxxxx>
References: <a184bff4e75445150ce75e7e273bd7bc1b0d273c.1494259970.git.joerg@xxxxxxxxxxxx>
From: =?UTF-8?q?J=C3=B6rg=20Sommer?= <joerg@xxxxxxxxxxxx>
Date: Mon, 8 May 2017 18:05:54 +0200
Subject: [PATCH 2/2] run-help-git: Print alias and skip shell commands
Print the definition of the git-alias like run-help does for shell
aliases. Git handles an alias starting with ! as a shell command. Hence,
there's no man-page for it.
---
Functions/Misc/run-help-git | 2 ++
1 file changed, 2 insertions(+)
diff --git a/Functions/Misc/run-help-git b/Functions/Misc/run-help-git
index ce94d0d02..3c8e6a150 100644
--- a/Functions/Misc/run-help-git
+++ b/Functions/Misc/run-help-git
@@ -3,6 +3,8 @@ if [ $# -eq 0 ]; then
else
local al
if al=$(git config --get "alias.$1"); then
+ builtin print -r "${run_help_orig_cmd:-git} $1 is a git-alias for $al"
+ [[ $al == !* ]] && return
1=${al%% *}
fi
man git-$1
--
2.11.0
Attachment:
signature.asc
Description: PGP signature