From 607a7a85b65527fb98e1a47c02dca6a777595eec Mon Sep 17 00:00:00 2001 From: Eric Cook Date: Sat, 31 Oct 2015 19:06:47 +0100 Subject: 36993: zed: fix argument parsing --- Functions/Misc/zed | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) (limited to 'Functions/Misc/zed') 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 -- cgit v1.2.3 From 8d1e882b78e3ccc3d66cfc61e1d7e3e53f60d67f Mon Sep 17 00:00:00 2001 From: Eric Cook Date: Tue, 27 Oct 2015 12:15:47 -0400 Subject: zed: Add -- to the `functions' builtin calls Reported on IRC: % autoload zed; zed -f -- "-zgen-prezto-load" zed:83: bad option: -g -zgen-prezto-load() { } --- ChangeLog | 6 ++++-- Functions/Misc/zed | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'Functions/Misc/zed') diff --git a/ChangeLog b/ChangeLog index 69f5182b9..0c26ced2e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,7 +1,9 @@ 2015-11-16 Mikael Magnusson - * Eric Cook: 37050: Completion/BSD/Command/_sockstat: _sockstat: - minor improvements + * Eric Cook: 36986: Functions/Misc/zed: Add -- to the `functions' + builtin calls + + * Eric Cook: 37050: Completion/BSD/Command/_sockstat: minor improvements 2015-11-15 Barton E. Schaefer diff --git a/Functions/Misc/zed b/Functions/Misc/zed index 94dd9ce5b..eb8f557ea 100644 --- a/Functions/Misc/zed +++ b/Functions/Misc/zed @@ -69,10 +69,10 @@ fi setopt localoptions nobanghist if ((fun)) then - var="$(functions $expand $1)" + var="$(functions $expand -- $1)" # If function is undefined but autoloadable, load it if [[ $var = *\#\ undefined* ]] then - var="$(autoload +X $1; functions $1)" + var="$(autoload +X $1; functions -- $1)" elif [[ -z $var ]] then var="$1() { }" -- cgit v1.2.3