Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] zed fails with setopt nounset unless option -x is given



> On 20 May 2022 at 15:06 Risto Laitinen <risto.laitinen@xxxxxxxxx> wrote:
> % zsh-5.9 -f
> % autoload zed
> % setopt nounset
> % zed a.txt
> zed:21: opts[-x]: parameter not set
> %

Looks straightforward.

zed runs as "emulate zsh"; it seems reasonable that nounset isn't
treated as an emulation option, given it's more for debugging, but
that means there could well be a lot more of these lurking.

pws

diff --git a/Functions/Misc/zed b/Functions/Misc/zed
index 7d0d590db..582a15d25 100644
--- a/Functions/Misc/zed
+++ b/Functions/Misc/zed
@@ -18,7 +18,7 @@ zparseopts -D -A opts f h b x:
 fun=$+opts[-f]
 hist=$+opts[-h]
 bind=$+opts[-b]
-if [[ $opts[-x] == <-> ]]; then
+if [[ $+opts[-x] == 1 && $opts[-x] == <-> ]]; then
   expand=(-x $opts[-x])
 elif (( $+opts[-x] )); then
   print -r "Integer expected after -x: $opts[-x]" >&2




Messages sorted by: Reverse Date, Date, Thread, Author