From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7199 invoked by alias); 8 May 2017 16:32:53 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 41072 Received: (qmail 9241 invoked from network); 8 May 2017 16:32:53 -0000 X-Qmail-Scanner-Diagnostics: from uucp.gnuu.de by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(85.214.128.138):SA:0(0.0/5.0):. Processed in 2.218441 secs); 08 May 2017 16:32:53 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RP_MATCHES_RCVD,SPF_PASS, T_SPF_HELO_PERMERROR autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: joerg@alea.gnuu.de X-Qmail-Scanner-Mime-Attachments: |signature.asc| X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at alea.gnuu.de designates 85.214.128.138 as permitted sender) Date: Mon, 8 May 2017 18:24:41 +0200 From: =?iso-8859-1?Q?J=F6rg?= Sommer To: zsh-workers@zsh.org Subject: [PATCH] run-help alias with variables, run-help-git better alias support Message-ID: <20170508162441.guz2q4untduwgojt@alea.gnuu.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="lgx5xzgrd7nsieey" Content-Disposition: inline User-Agent: NeoMutt/20170306 (1.8.0) --lgx5xzgrd7nsieey Content-Type: multipart/mixed; boundary="xrjdwwby4hzb2ndt" Content-Disposition: inline --xrjdwwby4hzb2ndt Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi, both patches are also available through my repository https://github.com/jo-so/zsh.git =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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=3D'LC_ALL=3DC true' % run-help T =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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=F6rg --xrjdwwby4hzb2ndt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-run-help-Support-variables-in-aliases.patch" Content-Transfer-Encoding: quoted-printable =46rom a184bff4e75445150ce75e7e273bd7bc1b0d273c Mon Sep 17 00:00:00 2001 Message-Id: =46rom: =3D?UTF-8?q?J=3DC3=3DB6rg=3D20Sommer?=3D 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=3D'LC_ALL=3DC 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 =3D *" is an alias "* ]] && continue builtin print -r $what case $what in - (*( is an alias for (noglob|nocorrect))*) - [[ ${what[(w)7]:t} !=3D ${what[(w)1]} ]] && - run_help_orig_cmd=3D${what[(w)1]} run-help ${what[(w)7]:t} - ;; (*( is an alias)*) - [[ ${what[(w)6]:t} !=3D ${what[(w)1]} ]] && - run_help_orig_cmd=3D${what[(w)1]} run-help ${what[(w)6]:t} + local cmd_idx=3D6 + while [[ ${what[(w)$cmd_idx]} =3D=3D *=3D* ]] + do + (( ++cmd_idx )) + done + [[ ${what[(w)$cmd_idx]} =3D=3D (noglob|nocorrect) ]] && + (( ++cmd_idx )) + [[ ${what[(w)$cmd_idx]:t} !=3D ${what[(w)1]} ]] && + run_help_orig_cmd=3D${what[(w)1]} run-help ${what[(w)$cmd_idx]:t} ;; (*( is a * function)) case ${what[(w)1]} in --=20 2.11.0 --xrjdwwby4hzb2ndt Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0002-run-help-git-Print-alias-and-skip-shell-commands.patch" Content-Transfer-Encoding: quoted-printable =46rom fe825e405b5bd9358718c2e5f1b0ba20b7d7cb9a Mon Sep 17 00:00:00 2001 Message-Id: In-Reply-To: References: =46rom: =3D?UTF-8?q?J=3DC3=3DB6rg=3D20Sommer?=3D 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=3D$(git config --get "alias.$1"); then + builtin print -r "${run_help_orig_cmd:-git} $1 is a git-alias for = $al" + [[ $al =3D=3D !* ]] && return 1=3D${al%% *} fi man git-$1 --=20 2.11.0 --xrjdwwby4hzb2ndt-- --lgx5xzgrd7nsieey Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQSUXHSAIM4XfczVbkTB7SZnAfVUgAUCWRCbxAAKCRDB7SZnAfVU gBrjAJ96JS6ynjsWLcNHm0ztHev5p7cQqgCgjFg4wZ8P53/KQ5VWxUMEeWq2E4A= =Ttqy -----END PGP SIGNATURE----- --lgx5xzgrd7nsieey--