* PATCH: _cd not completing in $cdpath
@ 1999-12-23 21:54 Peter Stephenson
1999-12-25 10:57 ` Arguments splitting (was: RE: PATCH: _cd not completing in $cdpath) Andrej Borsenkow
0 siblings, 1 reply; 2+ messages in thread
From: Peter Stephenson @ 1999-12-23 21:54 UTC (permalink / raw)
To: Zsh hackers list
(Andrej just reported this after I'd noticed it. I've left in the fact
that . gets removed. I think this is to do with the local-directories and
path-directories tag being separate; local files do get completed at some
point.)
_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.
The simple solution, passing the name of a parameter instead of the
concocted string, took me ages to think of. It turns out then that an
extra fix is required in _path_files for directories with spaces in: the
parameter was split with an extra ${=...}, which seems to me unnecessary
since it should be a proper array anyway, that's what they're for.
Index: Completion/Builtins/_cd
===================================================================
RCS file: /home/pws/CVSROOT/projects/zsh/Completion/Builtins/_cd,v
retrieving revision 1.3
diff -u -r1.3 _cd
--- Completion/Builtins/_cd 1999/12/15 19:44:32 1.3
+++ Completion/Builtins/_cd 1999/12/23 15:51:12
@@ -37,9 +37,11 @@
PREFIX="~$PREFIX"
_path_files -/
else
+ local tmpcdpath
+ tmpcdpath=(${(@)cdpath:#.})
_alternative \
'local-directories:local directories:_path_files -/' \
- "path-directories: directories in cdpath:_path_files -W \\(${${(@)cdpath:#.}}\\) -/"
+ "path-directories:directories in cdpath:_path_files -W tmpcdpath -/"
fi
else
_path_files -/
Index: Completion/Core/_path_files
===================================================================
RCS file: /home/pws/CVSROOT/projects/zsh/Completion/Core/_path_files,v
retrieving revision 1.10
diff -u -r1.10 _path_files
--- Completion/Core/_path_files 1999/12/15 19:44:32 1.10
+++ Completion/Core/_path_files 1999/12/23 15:47:25
@@ -44,7 +44,9 @@
if [[ "$tmp1[1]" = '(' ]]; then
prepaths=( ${^=tmp1[2,-2]%/}/ )
else
- prepaths=( ${(P)^=tmp1%/}/ )
+ # In this case the variable should be an array, so
+ # don't use an extra ${=...}.
+ prepaths=( ${(P)^tmp1%/}/ )
(( ! $#prepaths )) && prepaths=( ${tmp1%/}/ )
fi
(( ! $#prepaths )) && prepaths=( '' )
--
Peter Stephenson <pws@pwstephenson.fsnet.co.uk>
^ permalink raw reply [flat|nested] 2+ messages in thread
* Arguments splitting (was: RE: PATCH: _cd not completing in $cdpath)
1999-12-23 21:54 PATCH: _cd not completing in $cdpath Peter Stephenson
@ 1999-12-25 10:57 ` Andrej Borsenkow
0 siblings, 0 replies; 2+ messages in thread
From: Andrej Borsenkow @ 1999-12-25 10:57 UTC (permalink / raw)
To: Peter Stephenson, Zsh hackers list
> _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.
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.
/andrej
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1999-12-25 10:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-12-23 21:54 PATCH: _cd not completing in $cdpath Peter Stephenson
1999-12-25 10:57 ` Arguments splitting (was: RE: PATCH: _cd not completing in $cdpath) Andrej Borsenkow
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).