zsh-users
 help / color / mirror / code / Atom feed
* Bug in _gnu_generic for "cp -a"?
@ 2010-05-19 12:57 Andy Spiegl
  2010-05-19 15:30 ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Spiegl @ 2010-05-19 12:57 UTC (permalink / raw)
  To: zsh-users

Hi,

I always had "compdef _gnu_generic cp" in my zsh completion config.

I don't remember since which version of zsh
but at least for a couple months now I get this:

 condor:~> cp -a .zshr<TAB>
 - -a -

instead of file completion.  Only for the parameter "-a"!

I guess I'll just won't use _gnu_generic for cp anymore
but do you have any idea why this is happening?
Are there any drawbacks of not using _gnu_generic?

Cheers,
 Andy.

-- 
 lƃǝıds ʎpuɐ




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

* Re: Bug in _gnu_generic for "cp -a"?
  2010-05-19 12:57 Bug in _gnu_generic for "cp -a"? Andy Spiegl
@ 2010-05-19 15:30 ` Bart Schaefer
  2010-05-19 17:37   ` Andy Spiegl
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2010-05-19 15:30 UTC (permalink / raw)
  To: zsh-users

On Wed, May 19, 2010 at 5:57 AM, Andy Spiegl <zsh.Andy@spiegl.de> wrote:
>
> I always had "compdef _gnu_generic cp" in my zsh completion config.

Is there a reason you wanted to override the _cp completer that is
provided by default?  Does it get something else wrong that
_gnu_generic solved?

> but at least for a couple months now I get this:
>
> condor:~> cp -a .zshr<TAB>
> - -a -

_gnu_generic attempts to parse the output of "cp --help" and build a
completion description from that.  If the parse gets confused because
the format of the help output has changed, it won't necessarily
produce a correct result.

What do you see with

% cp -<TAB>

(that is, attempt to complete the list of options)?


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

* Re: Bug in _gnu_generic for "cp -a"?
  2010-05-19 15:30 ` Bart Schaefer
@ 2010-05-19 17:37   ` Andy Spiegl
  2010-05-20 14:45     ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Spiegl @ 2010-05-19 17:37 UTC (permalink / raw)
  To: zsh-users

On 2010-05-19, 08:30, Bart Schaefer wrote:
>
> Is there a reason you wanted to override the _cp completer that is
> provided by default?  Does it get something else wrong that
> _gnu_generic solved?
To be honest, I can't remember.  I added this line to my config
years ago and unfortunately didn't add a comment.  But I assume
that the _cp completer had some kind of problem back then.

> What do you see with
>
> % cp -<TAB>
>
condor:~/tmp> compdef _gnu_generic cp
condor:~/tmp> cp -<TAB>
- option -
--archive                 -a      -- same as -dR --preserve=all
-b                                -- like --backup but does not accept an argument
--backup                          -- make a backup of each existing destination file
--copy-contents                   -- copy contents of special files when recursive
-d                                -- same as --no-dereference --preserve=links
--dereference             -L      -- always follow symbolic links in SOURCE
--force                   -f      -- if an existing destination file cannot be
-H                                -- follow command-line symbolic links in SOURCE
--help                            -- display this help and exit
--interactive                     -- prompt before overwrite (overrides a previous -n
--link                    -l      -- link files instead of copying
--no-clobber              -n      -- do not overwrite an existing file (overrides
--no-dereference          -P      -- never follow symbolic links in SOURCE
--no-preserve                     -- don't preserve the specified attributes
--no-target-directory     -T      -- treat DEST as a normal file
--one-file-system         -x      -- stay on this file system
-p                                -- same as --preserve=mode,ownership,timestamps
--parents                         -- use full source file name under DIRECTORY
--preserve                        -- preserve the specified attributes (default-
--recursive               -r  -R  -- copy directories recursively
--remove-destination              -- remove each existing destination file before
--sparse                          -- control creation of sparse files
--strip-trailing-slashes          -- remove any trailing slashes from each SOURCE
--suffix                  -S      -- override the usual backup suffix
--symbolic-link           -s      -- make symbolic links instead of copying
--target-directory        -t      -- copy all SOURCE arguments into DIRECTORY
--update                  -u      -- copy only when the SOURCE file is newer
--verbose                 -v      -- explain what is being done
--version                         -- output version information and exit


With the default _cp completer:

condor:~/tmp> cp -<TAB>
- option -
--archive                 -a      -- same as -dpR
-b                                -- backup
--backup                          -- method
--copy-contents                   -- copy contents of special files when recursive
-d                                -- same as --no-dereference --preserve=link
--dereference             -L      -- always follow symbolic links
--force                   -f      -- remove and retry for destinations that cannot be opened
-H                                -- follow command-line symbolic links
--link                    -l      -- link files instead of copying
--no-preserve                     -- attributes not to preserve
--one-file-system         -x      -- stay on this file system
-p                                -- same as --preserve=mode,ownership,timestamps
-P                                -- same as --no-dereference
--parents                         -- append source path to target directory
--preserve                        -- attributes to preserve
--recursive               -r  -R  -- copy directories recursively
--remove-destination              -- remove each existing destination file before attempting to open it
--reply                           -- how to handle the prompt about an existing destination file
--sparse                          -- when to create sparse files
--strip-trailing-slashes          -- remove any trailing slashes from each source argument
--suffix                  -S      -- backup suffix
--symbolic-link           -s      -- make symbolic links instead of copies of non-directories
--target-directory                -- target directory
--update                  -u      -- copy only when source is newer than destination or destination is
--verbose                 -v      -- explain what is being done
--help                                             --version

condor:~> echo $ZSH_VERSION
4.3.10
condor:~> uname -a
Linux condor 2.6.31-21-generic #59-Ubuntu SMP Wed Mar 24 07:28:27 UTC 2010 x86_64 GNU/Linux
condor:~> cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=9.10
DISTRIB_CODENAME=karmic
DISTRIB_DESCRIPTION="Ubuntu 9.10"

Cheerio,
 Andy.


-- 
 lƃǝıds ʎpuɐ


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

* Re: Bug in _gnu_generic for "cp -a"?
  2010-05-19 17:37   ` Andy Spiegl
@ 2010-05-20 14:45     ` Bart Schaefer
  2010-05-22  2:46       ` Andy Spiegl
  0 siblings, 1 reply; 6+ messages in thread
From: Bart Schaefer @ 2010-05-20 14:45 UTC (permalink / raw)
  To: zsh-users

On Wed, May 19, 2010 at 10:37 AM, Andy Spiegl <zsh.Andy@spiegl.de> wrote:
> On 2010-05-19, 08:30, Bart Schaefer wrote:
>>
>> What do you see with
>>
>> % cp -<TAB>
>>
> condor:~/tmp> compdef _gnu_generic cp
> condor:~/tmp> cp -<TAB>
> - option -
> --archive                 -a      -- same as -dR --preserve=all
> -d                                -- same as --no-dereference --preserve=links

So, I have a suspicion that the "=" in the description is fooling
"_arguments ... --" into thinking that the -a option wants an argument
of its own.  (I haven't really worked out what's going on in the help
text parsing in there, so I may be way off.)  You said before that you
have this completion problem only with the -a option, but do you by
chance also have it with the -d option, which also has an "=" in the
description?


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

* Re: Bug in _gnu_generic for "cp -a"?
  2010-05-20 14:45     ` Bart Schaefer
@ 2010-05-22  2:46       ` Andy Spiegl
  2010-05-22  6:14         ` Bart Schaefer
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Spiegl @ 2010-05-22  2:46 UTC (permalink / raw)
  To: zsh-users

On 2010-05-20, 07:45, Bart Schaefer wrote:
> On Wed, May 19, 2010 at 10:37 AM, Andy Spiegl <zsh.Andy@spiegl.de> wrote:
> > On 2010-05-19, 08:30, Bart Schaefer wrote:
> >>
> You said before that you have this completion problem only with the
> -a option, but do you by chance also have it with the -d option,
> which also has an "=" in the description?

I tested and: YES
Also with -p which also has an "=" in the help description.
So I guess your assumption is very good!

Bye,
 Andy.

-- 
 lƃǝıds ʎpuɐ


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

* Re: Bug in _gnu_generic for "cp -a"?
  2010-05-22  2:46       ` Andy Spiegl
@ 2010-05-22  6:14         ` Bart Schaefer
  0 siblings, 0 replies; 6+ messages in thread
From: Bart Schaefer @ 2010-05-22  6:14 UTC (permalink / raw)
  To: zsh-users

On Fri, May 21, 2010 at 7:46 PM, Andy Spiegl <zsh.Andy@spiegl.de> wrote:
> On 2010-05-20, 07:45, Bart Schaefer wrote:
>> On Wed, May 19, 2010 at 10:37 AM, Andy Spiegl <zsh.Andy@spiegl.de> wrote:
>> > On 2010-05-19, 08:30, Bart Schaefer wrote:
>> >>
>> You said before that you have this completion problem only with the
>> -a option, but do you by chance also have it with the -d option,
>> which also has an "=" in the description?
>
> I tested and: YES
> Also with -p which also has an "=" in the help description.
> So I guess your assumption is very good!

OK, so the problem seems to be here:

      # Ignore :descriptions at the ends of lopts for matching this;
      # they aren't in the patterns.
      tmp=("${(@M)lopts:##$~pattern(|:*)}")
      lopts=("${(@)lopts:##$~pattern(|:*)}")

I'm still not quite following this, but I think that stuff is supposed
to distinguish descriptions of options from descriptions of the
arguments those options accept.  If that doesn't happen correctly, the
options having descriptions containing an "=" later reach this ...

      # Descriptions with `=': mandatory argument.
      # Basically the same as the foregoing.
      # TODO: could they be combined?

      tmpo=("${(@M)tmp:#*\=*}")
      if (( $#tmpo )); then
        tmp=("${(@)tmp:#*\=*}")

and in that block they get transformed from e.g -a:description: to
-a=[description] which is wrong.


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

end of thread, other threads:[~2010-05-22  6:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-19 12:57 Bug in _gnu_generic for "cp -a"? Andy Spiegl
2010-05-19 15:30 ` Bart Schaefer
2010-05-19 17:37   ` Andy Spiegl
2010-05-20 14:45     ` Bart Schaefer
2010-05-22  2:46       ` Andy Spiegl
2010-05-22  6:14         ` 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).