about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEric Cook <llua@gmx.com>2015-10-31 19:06:47 +0100
committerOliver Kiddle <opk@zsh.org>2015-10-31 19:06:47 +0100
commit607a7a85b65527fb98e1a47c02dca6a777595eec (patch)
tree10ed3ce85e356bdb6360b03a852803990dd3492d
parent682e779a211fdfa0baa41c06d821f0ea9acf4941 (diff)
downloadzsh-607a7a85b65527fb98e1a47c02dca6a777595eec.tar.gz
zsh-607a7a85b65527fb98e1a47c02dca6a777595eec.tar.xz
zsh-607a7a85b65527fb98e1a47c02dca6a777595eec.zip
36993: zed: fix argument parsing
-rw-r--r--ChangeLog4
-rw-r--r--Functions/Misc/zed31
2 files changed, 14 insertions, 21 deletions
diff --git a/ChangeLog b/ChangeLog
index a35b6056f..9068f13a0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2015-10-31  Oliver Kiddle  <opk@zsh.org>
+
+	* 36993: Eric Cook: Functions/Misc/zed: fix argument parsing
+
 2015-10-31  Barton E. Schaefer  <schaefer@zsh.org>
 
 	* unposted (cf. 36998,36999): Src/mem.c: undo 36956 / restore 34451
diff --git a/Functions/Misc/zed b/Functions/Misc/zed
index 010b69bee..94dd9ce5b 100644
--- a/Functions/Misc/zed
+++ b/Functions/Misc/zed
@@ -6,31 +6,20 @@
 # Use ^X^W to save, ^C to abort.
 # Option -f: edit shell functions.  (Also if called as fned.)
 
-local var opt zed_file_name
+local var opts zed_file_name
 # We do not want timeout while we are editing a file
 integer TMOUT=0 okargs=1 fun bind
 local -a expand
 
-while getopts "fbx:" opt; do
-  case $opt in
-    (f)
-    fun=1
-    ;;
-
-    (b)
-    bind=1
-    ;;
-
-    (x)
-    if [[ $OPTARG != <-> ]]; then
-      print -r "Integer expected after -x: $OPTARG" >&2
-      return 1
-    fi
-    expand=(-x $OPTARG)
-    ;;
-  esac
-done
-shift $(( OPTIND - 1 ))
+zparseopts -D -A opts f b x:
+fun=$+opts[-f]
+bind=$+opts[-b]
+if [[ $opts[-x] == <-> ]]; then
+  expand=(-x $opts[-x])
+elif (( $+opts[-x] )); then
+  print -r "Integer expected after -x: $opts[-x]" >&2
+  return 1
+fi
 
 [[ $0 = fned ]] && fun=1
 (( bind )) && okargs=0