zsh-users
 help / color / mirror / code / Atom feed
* safe completion functions
@ 2005-10-28 17:14 Steve Borho
  2005-10-28 17:29 ` Clint Adams
  2005-10-28 17:31 ` Andrey Borzenkov
  0 siblings, 2 replies; 4+ messages in thread
From: Steve Borho @ 2005-10-28 17:14 UTC (permalink / raw)
  To: zsh-users

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

Hello everyone.

I'm trying to write a somewhat feature-full completion function for the new 
bazaar 2.0 (aka bzr) revision control system.

The bzr developers have recently added some command line functions that can 
list files with NULL terminators, just like find.  Unfortunately, I can't get 
the completion functions to work correctly.

my completion function for add looks like this (in a nutshell):

  (add)
       _arguments $helpArgs \
       '--no-recurse[do not recurse into subdirectories]' \
       '(-q)--quiet' \
       '(--quiet)-q' \
       '*:unknown files:_unknownFiles'
  ;;

_unknownFiles() {
    local fileList;
    fileList=($(bzr ls --null --unknown))
    compadd -af fileList
    return 0
}

When I test it, I get: this

% cd repo
% touch "foo bar" baz zed
% bzr add [TAB]
     bar  baz  foo  zed

It's somehow splitting "foo\ bar" into "foo",  " ",  "bar".  I seem to be 
missing something obvious.  Can anyone help?

-- 
Steve Borho (steve@borho.org)
http://www.borho.org/~steve/steve.asc
Key fingerprint = 2D08 E7CF B624 624C DE1F  E2E4 B0C2 5292 F2C6 2C8C

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* Re: safe completion functions
  2005-10-28 17:14 safe completion functions Steve Borho
@ 2005-10-28 17:29 ` Clint Adams
  2005-10-28 18:06   ` Steve Borho
  2005-10-28 17:31 ` Andrey Borzenkov
  1 sibling, 1 reply; 4+ messages in thread
From: Clint Adams @ 2005-10-28 17:29 UTC (permalink / raw)
  To: Steve Borho; +Cc: zsh-users

>     fileList=($(bzr ls --null --unknown))

Try something like

fileList=(${(ps:\0:)"$(bzr ls --null --unknown)"})

instead


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

* Re: safe completion functions
  2005-10-28 17:14 safe completion functions Steve Borho
  2005-10-28 17:29 ` Clint Adams
@ 2005-10-28 17:31 ` Andrey Borzenkov
  1 sibling, 0 replies; 4+ messages in thread
From: Andrey Borzenkov @ 2005-10-28 17:31 UTC (permalink / raw)
  To: zsh-users; +Cc: Steve Borho

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Friday 28 October 2005 21:14, Steve Borho wrote:
> _unknownFiles() {
>     local fileList;
>     fileList=($(bzr ls --null --unknown))

try fileList=( ${(ps:\C-@:"$(bzr ls --null --unknown)"} )

- -andrey
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)

iD8DBQFDYmCPR6LMutpd94wRAvGdAKCniDUpNukWUp0J1dntdb788UFcLwCfQ4jK
se3LavwEwXaEkdPDJSNnRRg=
=6Tbt
-----END PGP SIGNATURE-----


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

* Re: safe completion functions
  2005-10-28 17:29 ` Clint Adams
@ 2005-10-28 18:06   ` Steve Borho
  0 siblings, 0 replies; 4+ messages in thread
From: Steve Borho @ 2005-10-28 18:06 UTC (permalink / raw)
  To: Clint Adams; +Cc: zsh-users

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

On Friday 28 October 2005 12:29, Clint Adams wrote:
> >     fileList=($(bzr ls --null --unknown))
>
> Try something like
>
> fileList=(${(ps:\0:)"$(bzr ls --null --unknown)"})
>
> instead

Fantastic.  Thanks.

-- 
Steve Borho (steve@borho.org)
http://www.borho.org/~steve/steve.asc
Key fingerprint = 2D08 E7CF B624 624C DE1F  E2E4 B0C2 5292 F2C6 2C8C

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

end of thread, other threads:[~2005-10-28 18:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-28 17:14 safe completion functions Steve Borho
2005-10-28 17:29 ` Clint Adams
2005-10-28 18:06   ` Steve Borho
2005-10-28 17:31 ` Andrey Borzenkov

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