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

Re: Globbing and RC_EXPAND_PARAM



Bart Schaefer wrote:

> On May 3, 10:41am, Sven Wischnowsky wrote:
> } Subject: Re: Globbing and RC_EXPAND_PARAM
> }
> } Not very nice either: *(/e:REPLY=-I\$REPLY)
> } 
> } Whoa! Dirty tricks ;-)
> 
> zagzig[86] echo *(/e:REPLY=-I\$REPLY)
> zsh: missing end of string

Sorry...

> zagzig[87] echo *(/e:REPLY=-I\$REPLY:)
> -ICVS -ICompletion -IConfig -IDoc -IEtc -IFunctions -IMisc -ISrc -IStartupFiles
> -ITest -IUtil
> 
> Pretty cool, but one can play hell with _expand this way ...
> 
> zagzig[91] echo Completion/*(/e:REPLY=-I\$REPLY:)
> zagzig[91] echo -I$REPLY -I$REPLY -I$REPLY -I$REPLY -I$REPLY -I$REPLY -I$REPLY
> -I$REPLY -I$REPLY -I$REPLY -I$REPLY
> Completing all expansions
> -I$REPLY -I$REPLY -I$REPLY -I$REPLY -I$REPLY -I$REPLY -I$REPLY -I$REPLY
> -I$REPLY -I$REPLY -I$REPLY
> Completing expansions
> -I$REPLY 
> Completing original
> Completion/*(/e:REPLY=-I\$REPLY:) 

With `substitute' set to zero, yes. Hrmpf, the ${(e)...} neatly
removes the backslash before the `$'. Since that isn't special to
globbing, I think we should just add to code to remove such
backslashes when `substitute' is zero.


And then I noticed that complist had a problem with clearing the end
of the previously shown list in a menu selection when the prompt went
from spanning multiple lines to only one line. Again. An off-by-one
error.


Bye
 Sven

Index: Completion/Core/_expand
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_expand,v
retrieving revision 1.7
diff -u -r1.7 _expand
--- Completion/Core/_expand	2000/05/02 15:52:44	1.7
+++ Completion/Core/_expand	2000/05/03 11:48:31
@@ -35,11 +35,14 @@
 # changes quoted spaces, tabs, and newlines into spaces and protects
 # this function from aborting on parse errors in the expansion.
 
-{ zstyle -s ":completion:${curcontext}:" substitute expr ||
-  { [[ "$curcontext" = expand-word:* ]] && expr=1 } } &&
-    [[ "${(e):-\$[$expr]}" -eq 1 ]] &&
-    exp=( ${(f)"$(print -lR - ${(e)exp//\\[ 	
+if { zstyle -s ":completion:${curcontext}:" substitute expr ||
+     { [[ "$curcontext" = expand-word:* ]] && expr=1 } } &&
+       [[ "${(e):-\$[$expr]}" -eq 1 ]]; then
+  exp=( ${(f)"$(print -lR - ${(e)exp//\\[ 	
 ]/ })"} ) 2>/dev/null
+else
+  exp=( "${exp:s/\\\$/\$}" )
+fi
 
 # If the array is empty, store the original string again.
 
@@ -117,7 +120,7 @@
       if [[ -d "$i" && "$i" != */ ]]; then
         dir=( "$dir[@]" "$i" )
       else
-	normal=( "$dir[@]" "$i" )
+	normal=( "$normal[@]" "$i" )
       fi
     done
     (( $#dir ))    && compadd "$expl[@]" -UQ -qS/ - "$dir[@]"
Index: Src/Zle/complist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/complist.c,v
retrieving revision 1.12
diff -u -r1.12 complist.c
--- Src/Zle/complist.c	2000/04/28 07:39:08	1.12
+++ Src/Zle/complist.c	2000/05/03 11:48:32
@@ -985,7 +985,7 @@
 	lastml = 0;
     }
     cl = (listdat.nlines > lines - nlnct - mhasstat ?
-	  lines - nlnct - mhasstat : listdat.nlines);
+	  lines - nlnct - mhasstat : listdat.nlines) - 1;
     mrestlines = lines - 1;
 
     if (cl < 2) {

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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