about summary refs log tree commit diff
path: root/Functions
diff options
context:
space:
mode:
authorMarlon Richert <marlon.richert@gmail.com>2021-09-06 13:45:36 -0700
committerBart Schaefer <schaefer@ipost.com>2021-09-06 13:47:10 -0700
commit1508dc7486636edcb54e81f6a2fcf0faf180c7fa (patch)
treecdab91cbac7e0c0b1268111ab0266173b11a4da7 /Functions
parent35c87f0b3bc0ce5a22a6bf3b0f2b2a14a3993cea (diff)
downloadzsh-1508dc7486636edcb54e81f6a2fcf0faf180c7fa.tar.gz
zsh-1508dc7486636edcb54e81f6a2fcf0faf180c7fa.tar.xz
zsh-1508dc7486636edcb54e81f6a2fcf0faf180c7fa.zip
49218: run-help filters cmd_args before calling run-help-<command>
Diffstat (limited to 'Functions')
-rw-r--r--Functions/Misc/run-help15
-rw-r--r--Functions/Misc/run-help-btrfs4
-rw-r--r--Functions/Misc/run-help-git10
-rw-r--r--Functions/Misc/run-help-ip4
-rw-r--r--Functions/Misc/run-help-p42
-rw-r--r--Functions/Misc/run-help-svk2
-rw-r--r--Functions/Misc/run-help-svn2
7 files changed, 13 insertions, 26 deletions
diff --git a/Functions/Misc/run-help b/Functions/Misc/run-help
index e351dd6a6..d52c1b032 100644
--- a/Functions/Misc/run-help
+++ b/Functions/Misc/run-help
@@ -101,12 +101,15 @@ do
 		builtin getln cmd_args
 		builtin print -z "$cmd_args"
 		cmd_args=( ${(z)cmd_args} )
-		# Discard environment assignments, etc.
-		while [[ $cmd_args[1] != ${run_help_orig_cmd:-$1} ]]
-		do
-		    shift cmd_args || return 1
-		done
-		eval "run-help-$1:t ${(q@)cmd_args[2,-1]}"
+
+                # Discard the command itself & everything before it.
+                shift $cmd_args[(i)${run_help_orig_cmd:-$1}] cmd_args ||
+                    return
+
+                # Discard options, parameter assignments & paths.
+                cmd_args=( ${cmd_args[@]:#([-+]*|*=*|*/*|\~*)} )
+
+                eval "run-help-$1:t ${(@q)cmd_args}"
 	    else
 		POSIXLY_CORRECT=1 man $@:t
 	    fi
diff --git a/Functions/Misc/run-help-btrfs b/Functions/Misc/run-help-btrfs
index 0dc1dabcb..cb139e9b7 100644
--- a/Functions/Misc/run-help-btrfs
+++ b/Functions/Misc/run-help-btrfs
@@ -1,7 +1,3 @@
-while [[ $# != 0 && $1 == -* ]]; do
-    shift
-done
-
 case $1 in
     (b*)    man btrfs-balance          ;;
     (c*)    man btrfs-check            ;;
diff --git a/Functions/Misc/run-help-git b/Functions/Misc/run-help-git
index ce94d0d02..a841f89d6 100644
--- a/Functions/Misc/run-help-git
+++ b/Functions/Misc/run-help-git
@@ -1,9 +1 @@
-if [ $# -eq 0 ]; then
-    man git
-else
-    local al
-    if al=$(git config --get "alias.$1"); then
-        1=${al%% *}
-    fi
-    man git-$1
-fi
+git help ${1:-git}
diff --git a/Functions/Misc/run-help-ip b/Functions/Misc/run-help-ip
index 8807f9ef1..b811ce352 100644
--- a/Functions/Misc/run-help-ip
+++ b/Functions/Misc/run-help-ip
@@ -14,10 +14,6 @@ if ! man -w ip-address >/dev/null 2>&1; then
     return
 fi
 
-while [[ $# != 0 && $1 == -* ]]; do
-    shift
-done
-
 case $1 in
     (addrl*) man ip-addrlabel ;;
     (a*) man ip-address ;;
diff --git a/Functions/Misc/run-help-p4 b/Functions/Misc/run-help-p4
index 662ce94fe..e48a4d068 100644
--- a/Functions/Misc/run-help-p4
+++ b/Functions/Misc/run-help-p4
@@ -2,4 +2,4 @@ if (( ! $# )); then
   p4 help commands
 else
   p4 help $1
-fi | ${=PAGER:-less}
+fi | ${=PAGER:-more}
diff --git a/Functions/Misc/run-help-svk b/Functions/Misc/run-help-svk
index 92438a53f..782538246 100644
--- a/Functions/Misc/run-help-svk
+++ b/Functions/Misc/run-help-svk
@@ -1 +1 @@
-svk help ${${@:#-*}[1]} | ${=PAGER:-more}
+svk help $1 | ${=PAGER:-more}
diff --git a/Functions/Misc/run-help-svn b/Functions/Misc/run-help-svn
index 5d1068588..d55a493a6 100644
--- a/Functions/Misc/run-help-svn
+++ b/Functions/Misc/run-help-svn
@@ -1 +1 @@
-svn help ${${@:#-*}[1]} | ${=PAGER:-more}
+svn help $1 | ${=PAGER:-more}