zsh-workers
 help / color / mirror / code / Atom feed
* Compatibility issue in the _django completion
@ 2013-01-11 19:14 Alexey Bezhan
  2013-12-27 21:15 ` PATCH _cd: completion fails for "cd .." if $PWD/.. contains a space Alexey Bezhan
  0 siblings, 1 reply; 7+ messages in thread
From: Alexey Bezhan @ 2013-01-11 19:14 UTC (permalink / raw)
  To: zsh-workers

[-- Attachment #1: Type: text/plain, Size: 758 bytes --]

Hi, 

There's a problem with the current _django completion function under Mac OS X: a call to "awk -vdrop=1" at line 59 results in the "awk: invalid -v option" error. Adding a space after "-v" fixes the problem and seems to work both in mawk in Ubuntu and awk in OS X (awk version 20070501).

--- i/Completion/Unix/Command/_django
+++ w/Completion/Unix/Command/_django
@@ -59,7 +59,7 @@ case $state in
     )
 
     for cmd in $(./manage.py --help 2>&1 >/dev/null | \
-        awk -vdrop=1 '{ if (!drop) print substr($0, 3) } /^Available subcommands/ { drop=0 }')
+        awk -v drop=1 '{ if (!drop) print substr($0, 3) } /^Available subcommands/ { drop=0 }')
     do
         if ! echo $subcommands | grep -qs "${cmd}:"
         then


-- 
Alexey Bezhan


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

* PATCH _cd: completion fails for "cd .." if $PWD/.. contains a space
  2013-01-11 19:14 Compatibility issue in the _django completion Alexey Bezhan
@ 2013-12-27 21:15 ` Alexey Bezhan
  2013-12-28  8:00   ` Bart Schaefer
  0 siblings, 1 reply; 7+ messages in thread
From: Alexey Bezhan @ 2013-12-27 21:15 UTC (permalink / raw)
  To: zsh-workers

Hi,

There’s a bug in _cd completion that results in empty result when trying to
complete after “cd ../” if there’s a space somewhere in $PWD/..

Steps to reproduce:
$ mkdir -p "a b/c”
$ cd "a b/c”
$ cd ../<TAB> # Results in `local directory’ and no completion suggestions.

The following patch fixes the space issue, but there may be other cases that
cause the same behavior that aren’t fixed by this change.

diff --git i/Completion/Zsh/Command/_cd w/Completion/Zsh/Command/_cd
index a5d328f..abd4fa0 100644
--- i/Completion/Zsh/Command/_cd
+++ w/Completion/Zsh/Command/_cd
@@ -57,7 +57,7 @@ else
# Use cd in a subshell to properly [not] resolve symlinks
tmpprefix=$(cd ${PREFIX%/*} >&/dev/null && print $PWD)
if [[ -n $tmpprefix ]]; then
- tmpWpath=(-W $tmpprefix)
+ tmpWpath=(-W \"$tmpprefix\")
IPREFIX=${IPREFIX}${PREFIX%/*}/
PREFIX=${PREFIX##*/}
fi

--
Alexey Bezhan


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

* Re: PATCH _cd: completion fails for "cd .." if $PWD/.. contains a space
  2013-12-27 21:15 ` PATCH _cd: completion fails for "cd .." if $PWD/.. contains a space Alexey Bezhan
@ 2013-12-28  8:00   ` Bart Schaefer
  2013-12-30  9:23     ` PATCH _cd: completion fails for Carlo
  0 siblings, 1 reply; 7+ messages in thread
From: Bart Schaefer @ 2013-12-28  8:00 UTC (permalink / raw)
  To: zsh-workers

On Dec 27,  9:15pm, Alexey Bezhan wrote:
}
} There's a bug in _cd completion that results in empty result when trying to
} complete after "cd ../" if there's a space somewhere in $PWD/..
} 
} The following patch fixes the space issue, but there may be other cases that
} cause the same behavior that aren't fixed by this change.
} 
} - tmpWpath=(-W $tmpprefix)
} + tmpWpath=(-W \"$tmpprefix\")

Thanks ... your patch seems to have been slightly mangled in transit.

After looking at this for a while I think you are close, but not quite
right.  There are two uses of $tmpWpath, but I believe only one of them
needs additional quoting.

This also needs to be careful to quote each element of the array before
the elements are joined, because the reference is inside double-quotes.


diff --git a/Completion/Zsh/Command/_cd b/Completion/Zsh/Command/_cd
index a5d328f..b9860ff 100644
--- a/Completion/Zsh/Command/_cd
+++ b/Completion/Zsh/Command/_cd
@@ -100,7 +100,7 @@ else
     # already handled by _command_names (see _autocd)
 
     [[ CURRENT -ne 1 || ( -z "$path[(r).]" && $PREFIX != */* ) ]] &&
-        alt=( "${cdpath+local-}directories:${cdpath+local }directory:_path_files $tmpWpath -/" "$alt[@]" )
+        alt=( "${cdpath+local-}directories:${cdpath+local }directory:_path_files ${(j: :)${(@q)tmpWpath}} -/" "$alt[@]" )
 
     if [[ CURRENT -eq argstart && noopts -eq 0 && $PREFIX = -* ]] &&
       zstyle -t ":completion:${curcontext}:options" complete-options; then


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

* Re: PATCH _cd: completion fails for
  2013-12-28  8:00   ` Bart Schaefer
@ 2013-12-30  9:23     ` Carlo
  2013-12-30 16:13       ` Carlo
  2013-12-30 16:15       ` Carlo
  0 siblings, 2 replies; 7+ messages in thread
From: Carlo @ 2013-12-30  9:23 UTC (permalink / raw)
  To: zsh-workers

Bart Schaefer <schaefer <at> brasslantern.com> writes:

> After looking at this for a while I think you are close, but not quite
> right.  There are two uses of $tmpWpath, but I believe only one of them
> needs additional quoting.
> 
> This also needs to be careful to quote each element of the array before
> the elements are joined, because the reference is inside double-quotes.


Hello Bart

I am afraid, your patch doesn't work for me.

Fetched zsh 5.0.4, built it on MacOS X 10.9.1.
When I hit the tab, the shell immediately exits.

It happens when it type

     cd /usr/lo<TAB>

as well as

     ls /tmp/g<TAB>

Applying your patch - using _cd from a fresh git checkout - hasn't fixed it.
The problem is not a space in a path, but in the handling of tab characters.

I have been using the same zsh key-bindings for years on various OS
without incurring this problem.

Reverted back to 5.0.2, where the tab character works as expected.


Regards,
--
Carlo



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

* Re: PATCH _cd: completion fails for
  2013-12-30  9:23     ` PATCH _cd: completion fails for Carlo
@ 2013-12-30 16:13       ` Carlo
  2013-12-30 16:15       ` Carlo
  1 sibling, 0 replies; 7+ messages in thread
From: Carlo @ 2013-12-30 16:13 UTC (permalink / raw)
  To: zsh-workers

Carlo <catull <at> gmail.com> writes:

> Bart Schaefer <schaefer <at> brasslantern.com> writes:
> 
> > After looking at this for a while I think you are close, but not quite
> > right.  There are two uses of $tmpWpath, but I believe only one of them
> > needs additional quoting.
> > 
> > This also needs to be careful to quote each element of the array before
> > the elements are joined, because the reference is inside double-quotes.
> 
> Hello Bart
> 
> I am afraid, your patch doesn't work for me.
> 
> It happens when it type
> 
>      cd /usr/lo<TAB>
> 
> as well as
> 
>      ls /tmp/g<TAB>

Found a solution.

It turns out the gcc I used (gcc (GCC) 4.9.0 20130811 (experimental)) built
many open source tools successfully, just not zsh.

It linked against a strange libiconv library, which gave a

With clang (Apple LLVM version 5.0 (clang-500.2.79)) the resulting zsh i
working now; did not have to apply your patch to _cd.


Regards,
--
Carlo



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

* Re: PATCH _cd: completion fails for
  2013-12-30  9:23     ` PATCH _cd: completion fails for Carlo
  2013-12-30 16:13       ` Carlo
@ 2013-12-30 16:15       ` Carlo
  2013-12-30 19:29         ` Bart Schaefer
  1 sibling, 1 reply; 7+ messages in thread
From: Carlo @ 2013-12-30 16:15 UTC (permalink / raw)
  To: zsh-workers

Carlo <catull <at> gmail.com> writes:

> Bart Schaefer <schaefer <at> brasslantern.com> writes:
> 
> > After looking at this for a while I think you are close, but not quite
> > right.  There are two uses of $tmpWpath, but I believe only one of them
> > needs additional quoting.
> > 
> > This also needs to be careful to quote each element of the array before
> > the elements are joined, because the reference is inside double-quotes.
> 
> Hello Bart
> 
> I am afraid, your patch doesn't work for me.
> 
> It happens when it type
> 
>      cd /usr/lo<TAB>
> 
> as well as
> 
>      ls /tmp/g<TAB>

Found a solution.

It turns out the gcc I used (gcc (GCC) 4.9.0 20130811 (experimental)) built
many open source tools successfully, just not zsh.

It linked against a strange libiconv library, which gave a

With clang (Apple LLVM version 5.0 (clang-500.2.79)) the resulting zsh i
working now; did not have to apply your patch to _cd.


Regards,
--
Carlo



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

* Re: PATCH _cd: completion fails for
  2013-12-30 16:15       ` Carlo
@ 2013-12-30 19:29         ` Bart Schaefer
  0 siblings, 0 replies; 7+ messages in thread
From: Bart Schaefer @ 2013-12-30 19:29 UTC (permalink / raw)
  To: zsh-workers

On Dec 30,  4:15pm, Carlo wrote:
}
} It turns out the gcc I used (gcc (GCC) 4.9.0 20130811 (experimental)) built
} many open source tools successfully, just not zsh.
} 
} It linked against a strange libiconv library, which gave a
} 
} With clang (Apple LLVM version 5.0 (clang-500.2.79)) the resulting zsh i
} working now; did not have to apply your patch to _cd.

I've made a note about this in the MACHINES file.  If anyone has any
other information (knows this is fixed with a different version of GCC,
for example) please let us know.


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

end of thread, other threads:[~2013-12-30 19:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-11 19:14 Compatibility issue in the _django completion Alexey Bezhan
2013-12-27 21:15 ` PATCH _cd: completion fails for "cd .." if $PWD/.. contains a space Alexey Bezhan
2013-12-28  8:00   ` Bart Schaefer
2013-12-30  9:23     ` PATCH _cd: completion fails for Carlo
2013-12-30 16:13       ` Carlo
2013-12-30 16:15       ` Carlo
2013-12-30 19:29         ` Bart Schaefer

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).