zsh-workers
 help / color / mirror / code / Atom feed
* PATCH: Re: Arguments splitting (was: RE: PATCH: _cd not completing in $cdpath)
@ 2000-01-04 12:43 Sven Wischnowsky
  2000-01-05  7:16 ` Andrej Borsenkow
  0 siblings, 1 reply; 3+ messages in thread
From: Sven Wischnowsky @ 2000-01-04 12:43 UTC (permalink / raw)
  To: zsh-workers


Andrej Borsenkow wrote:

> > _alternative re-evaluates arguments passed to it, so a string like
> >  '\(/home/pws /home/pws/tex\)'
> > isn't good enough as a path for _path_files -W because it gets split on
> > spaces, whereas _path_files needs it as a single argument.  If that's the
> > correct behaviour for _alternative --- and I suspect it is, because there
> > are uses like
> >   _alternative 'files:: _files' 'parameters:: _parameters'
> > --- then _cd needs fixing.
> >
> 
> It is correct, that arguments, that are command line, need splitting (to get at
> this command line at all :-) But the current way to split them prevents any
> arguments with embedded LFS characters.
> 
> What about something like
> 
> eval "action=( $action )"
> 
> Then we could define
> 
> _alternative 'files::_files -W "(a b c)"'
> 
> i.e. just use usual quoting.

Right. When I first wrote the stuff I wanted to avoid such a
`eval'. That seems ridiculous nowadays...

> Note, that this (possibly - I did not check the code) applies to _arguments,
> _values etc - to any function, that is possibly using this format. It seems that
> a single utility function/builtin to habdle such arguments is quite timely.

I know that I started to do that at least once. But then found enough
differences between them to make me stop doing that. So, the patch
patches all three files without moving code into a helper function,
but, unless I have forgotten something else, it should be possible
(the different handling of `->state' actions may be a problem, but I
don't really remember the problems I encountered).

Bye
 Sven

diff -ru ../z.old/Completion/Base/_arguments Completion/Base/_arguments
--- ../z.old/Completion/Base/_arguments	Tue Jan  4 13:22:22 2000
+++ Completion/Base/_arguments	Tue Jan  4 13:32:05 2000
@@ -246,13 +246,14 @@
 
             # If the action starts with a space, we just call it.
 
-            ${(e)=~action}
+	    eval "action=( $action )"
+            "$action[@]"
           else
 
             # Otherwise we call it with the description-arguments built above.
 
-            action=( $=action )
-            ${(e)action[1]} "$subopts[@]" "$expl[@]" ${(e)~action[2,-1]}
+            eval "action=( $action )"
+            "$action[1]" "$subopts[@]" "$expl[@]" "${(@)action[2,-1]}"
           fi
         fi
       fi
diff -ru ../z.old/Completion/Base/_values Completion/Base/_values
--- ../z.old/Completion/Base/_values	Tue Jan  4 13:22:23 2000
+++ Completion/Base/_values	Tue Jan  4 13:34:08 2000
@@ -130,13 +130,14 @@
 
       # If the action starts with a space, we just call it.
 
-      ${(e)=~action}
+      eval "action=( $action )"
+      "$action[@]"
     else
 
       # Otherwise we call it with the description-arguments built above.
 
-      action=( $=action )
-      ${(e)action[1]} "$subopts[@]" "$expl[@]" ${(e)~action[2,-1]}
+      eval "action=( $action )"
+      "$action[1]" "$subopts[@]" "$expl[@]" "${(@)action[2,-1]}"
     fi
   fi
 
diff -ru ../z.old/Completion/Core/_alternative Completion/Core/_alternative
--- ../z.old/Completion/Core/_alternative	Tue Jan  4 13:22:30 2000
+++ Completion/Core/_alternative	Tue Jan  4 13:35:01 2000
@@ -54,13 +54,14 @@
 
         # If the action starts with a space, we just call it.
 
-        ${(e)=~action}
+        eval "action=( $action )"
+        "$action[@]"
       else
 
         # Otherwise we call it with the description-arguments built above.
 
-        action=( $=action )
-        ${(e)action[1]} "$subopts[@]" "$expl[@]" ${(e)~action[2,-1]}
+        eval "action=( $action )"
+        "$action[1]" "$subopts[@]" "$expl[@]" "${(@)action[2,-1]}"
       fi
     fi
   done

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: PATCH: Re: Arguments splitting (was: RE: PATCH: _cd not completing in $cdpath)
  2000-01-04 12:43 PATCH: Re: Arguments splitting (was: RE: PATCH: _cd not completing in $cdpath) Sven Wischnowsky
@ 2000-01-05  7:16 ` Andrej Borsenkow
  0 siblings, 0 replies; 3+ messages in thread
From: Andrej Borsenkow @ 2000-01-05  7:16 UTC (permalink / raw)
  To: Sven Wischnowsky, zsh-workers

>
> Right. When I first wrote the stuff I wanted to avoid such a
> `eval'. That seems ridiculous nowadays...
>

Is it possible to document, how many times arguments get expanded/evaled in
which case? Does it happen just once or possibly more than once?

/andrej


^ permalink raw reply	[flat|nested] 3+ messages in thread

* RE: PATCH: Re: Arguments splitting (was: RE: PATCH: _cd not completing in $cdpath)
@ 2000-01-05  9:14 Sven Wischnowsky
  0 siblings, 0 replies; 3+ messages in thread
From: Sven Wischnowsky @ 2000-01-05  9:14 UTC (permalink / raw)
  To: zsh-workers


Andrej Borsenkow wrote:

> > Right. When I first wrote the stuff I wanted to avoid such a
> > `eval'. That seems ridiculous nowadays...
> >
> 
> Is it possible to document, how many times arguments get expanded/evaled in
> which case? Does it happen just once or possibly more than once?

Should be only once if I'm not completely mistaken. Just as it was
before, as it was before and, hopefully, as everyone would expect it.

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2000-01-05  9:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-01-04 12:43 PATCH: Re: Arguments splitting (was: RE: PATCH: _cd not completing in $cdpath) Sven Wischnowsky
2000-01-05  7:16 ` Andrej Borsenkow
2000-01-05  9:14 Sven Wischnowsky

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).