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

[BUG+PATCH] Let _expand preserve array form w/out zstyle glob



This is the bug:

% autoload compinit; compinit
% typeset -g tst=(a b)
% : $tst^D
expansions
a  b
% zstyle '*' glob no
% : $tst
expansions
a\ b

I would expect the output to be the same, since we're not globbing here.

Below is the fix.
From d92ac7a8708cdb31e1a9cc5e7430558414233f19 Mon Sep 17 00:00:00 2001
From: Marlon Richert <marlonrichert@xxxxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 12 Nov 2021 21:52:18 +0200
Subject: [PATCH] Let _expand preserve array form w/out zstyle glob

---
 Completion/Base/Completer/_expand |  2 +-
 Test/Y01completion.ztst           | 11 +++++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/Completion/Base/Completer/_expand b/Completion/Base/Completer/_expand
index 86b4ac6e4..e5e4f9b39 100644
--- a/Completion/Base/Completer/_expand
+++ b/Completion/Base/Completer/_expand
@@ -105,7 +105,7 @@ subd=("$exp[@]")
 
 # We need to come out of this with consistent quoting, by hook or by crook.
 integer done_quote
-local orig_exp=$exp
+local -a orig_exp=( $exp )
 if [[ "$force" = *g* ]] || zstyle -T ":completion:${curcontext}:" glob; then
   eval 'exp=( ${~exp//(#b)\\([ 	\"'"\'"'
 ])/$match[1]} ); exp=( ${(q)exp} )' 2>/dev/null && (( $#exp )) && done_quote=1
diff --git a/Test/Y01completion.ztst b/Test/Y01completion.ztst
index 882a0adc4..6af0efc6d 100644
--- a/Test/Y01completion.ztst
+++ b/Test/Y01completion.ztst
@@ -62,6 +62,17 @@
 >line: {: dir1 dir2 file1 file2 }{}
 >line: {: *}{}
 
+  comptesteval $'zstyle \'*\' glob no'
+  comptesteval $'typeset -g tst=(*)'
+  comptest $': $tst\C-D'
+0:_expand preserves array form
+>DESCRIPTION:{expansions}
+>NO:{dir1}
+>NO:{dir2}
+>NO:{file1}
+>NO:{file2}
+
+  comptesteval $'zstyle -d \'*\' glob'
   comptesteval '_users () { compadd user1 user2 }'
   comptest $': ~\t\t\t\t\t'
 0:tilde
-- 
2.30.1 (Apple Git-130)



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