zsh-workers
 help / color / mirror / code / Atom feed
* Re: Bug#390574: zsh: Updated completions for schroot and dchroot
       [not found] <20061001210027.13349.94075.reportbug@hardknott.home>
@ 2006-10-01 21:49 ` Clint Adams
       [not found]   ` <874punel7y.fsf@hardknott.home>
  0 siblings, 1 reply; 3+ messages in thread
From: Clint Adams @ 2006-10-01 21:49 UTC (permalink / raw)
  To: Roger Leigh, 390574; +Cc: zsh-workers

> Hi,
> 
> Attached is a patch to update the completions for schroot and dchroot, and also
> to add completions for dchroot-dsa.
> 
> Since I'm new to zsh, some parts of the patch might be suboptimal.  Feel free to
> alter it.  The bit I'm not sure about is:
> 
> -  compadd ${${$(dchroot -l)[3,-1]%,}:#\[*\]} && ret=0
> +  compadd $(echo ${$(dchroot -l)[3,-1]%,} | sed -e 's/\[//g' -e 's/\]//g' | sort | uniq)
> 
> The output of dchroot:
> 
> % dchroot -l
> Available chroots: experimental, fake, sarge [stable, sarge-backports], sid [unstable, unstable-sbuild], sid-block [sid-block], sid-file, sid-file-source, sid-snap, sid-snap-source, testsnap, testsnap-source
> 
> The ,[] all need stripping, and duplicates need removing.  The old code assumes
> there will only be one name in square brackets, but this is no longer the case.
> I didn't find a way to do this with the zsh shell ${} operations.

Yes, you can do it with something like this (the line break is literal)

${(os:,:)${${${"$(dchroot -l)"#Available chroots: }/\[*\]/}//[  
]/}}

I'll tweak the patch.

> diff -urN zsh-4.3.2.original/Completion/Debian/Command/_dchroot zsh-4.3.2/Completion/Debian/Command/_dchroot
> --- zsh-4.3.2.original/Completion/Debian/Command/_dchroot	2005-11-25 09:45:33.000000000 +0000
> +++ zsh-4.3.2/Completion/Debian/Command/_dchroot	2006-10-01 21:48:22.030202507 +0100
> @@ -1,18 +1,27 @@
>  #compdef dchroot
>  
> -local curcontext="$curcontext" state line expl ret=1
> +local expl context state line
> +typeset -A opt_args
>  
> -_arguments -C \
> -  '(-c -l -h -V)-a[execute in all known chroots]' \
> -  '(-a -l -h -V)-c[execute in specified chroot]:chroot:->chroots' \
> -  '(- *)-l[list available chroots]' \
> -  '(-l)-d[preserve environment in chroot]' \
> -  '(-h -l -V)-q[be quiet]' \
> -  '(- *)-h[display help information]' \
> -  '(- *)-V[display version information]' \
> -  '*::args: _normal' && ret=0
> +_arguments -S \
> +       '(-h --help)'{-h,--help}'[help]' \
> +       '(-a --all)'{-a,--all}'[select all chroots]' \
> +       '*'{-c,--chroot=}'[use specified chroot]:chroot:->chroot' \
> +       '(-d --directory)'{-d,--directory=}'[directory to use]:dir:_files -W / -P /' \
> +       '(-l --list)'{-l,--list}'[list available chroots]' \
> +       '(-i --info)'{-i,--info}'[show information about selected chroots]' \
> +       '(-p --path)'{-p,--path}'[print path to selected chroot]' \
> +       '--config[dump configuration of selected chroots]' \
> +       '(-d --preserve-environment)'{-d,--preserve-environment}'[preserve user environment]' \
> +       '(-q --quiet)'{-q,--quiet}'[quiet]' \
> +       '(-v --verbose)'{-v,--verbose}'[verbose]' \
> +       '(-V --version)'{-V,--version}'[version]' \
> +       '(-):command name: _command_names -e' \
> +       '*::arguments: _normal' && return 0
>  
> -[[ -n $state ]] && _wanted chroots expl chroot \
> -    compadd ${${$(dchroot -l)[3,-1]%,}:#\[*\]} && ret=0
> -
> -return ret
> +case "$state" in
> +	(chroot)
> +	_wanted tag expl 'chroot' \
> +	compadd $(echo ${$(dchroot -l)[3,-1]%,} | sed -e 's/\[//g' -e 's/\]//g' | sort | uniq)
> +	;;
> +esac
> diff -urN zsh-4.3.2.original/Completion/Debian/Command/_dchroot-dsa zsh-4.3.2/Completion/Debian/Command/_dchroot-dsa
> --- zsh-4.3.2.original/Completion/Debian/Command/_dchroot-dsa	1970-01-01 01:00:00.000000000 +0100
> +++ zsh-4.3.2/Completion/Debian/Command/_dchroot-dsa	2006-10-01 21:49:02.110202507 +0100
> @@ -0,0 +1,26 @@
> +#compdef dchroot-dsa
> +
> +local expl context state line
> +typeset -A opt_args
> +
> +_arguments -S \
> +       '(-h --help)'{-h,--help}'[help]' \
> +       '(-a --all)'{-a,--all}'[select all chroots]' \
> +       '*'{-c,--chroot=}'[use specified chroot]:chroot:->chroot' \
> +       '(-d --directory)'{-d,--directory=}'[directory to use]:dir:_files -W / -P /' \
> +       '(-l --list)'{-l,--list}'[list available chroots]' \
> +       '(-i --info)'{-i,--info}'[show information about selected chroots]' \
> +       '(-p --listpaths)'{-p,--listpaths}'[print paths to available chroots]' \
> +       '--config[dump configuration of selected chroots]' \
> +       '(-q --quiet)'{-q,--quiet}'[quiet]' \
> +       '(-v --verbose)'{-v,--verbose}'[verbose]' \
> +       '(-V --version)'{-V,--version}'[version]' \
> +       '(-):command name: _command_names -e' \
> +       '*::arguments: _normal' && return 0
> +
> +case "$state" in
> +	(chroot)
> +	_wanted tag expl 'chroot' \
> +	compadd $(echo ${$(dchroot -l)[3,-1]%,} | sed -e 's/\[//g' -e 's/\]//g' | sort | uniq)
> +	;;
> +esac
> diff -urN zsh-4.3.2.original/Completion/Debian/Command/_schroot zsh-4.3.2/Completion/Debian/Command/_schroot
> --- zsh-4.3.2.original/Completion/Debian/Command/_schroot	2006-02-27 02:08:29.000000000 +0000
> +++ zsh-4.3.2/Completion/Debian/Command/_schroot	2006-10-01 21:45:06.762202507 +0100
> @@ -5,30 +5,30 @@
>  
>  _arguments -S \
>         '(-h --help)'{-h,--help}'[help]' \
> -       '(-a --all)'{-a,--all}'[all chroots and active sessions]' \
> -       '--all-chroots' \
> -       '--all-sessions' \
> -       '*'{-c,--chroot=}':chroot:->chroot' \
> -       '(-u --user)'{-u,--user=}':user:_users' \
> +       '(-a --all)'{-a,--all}'[select all chroots and active sessions]' \
> +       '--all-chroots[select all chroots]' \
> +       '--all-sessions[select all active sessions]' \
> +       '*'{-c,--chroot=}'[use specified chroot]:chroot:->chroot' \
> +       '(-d --directory)'{-d,--directory=}'[directory to use]:dir:_files -W / -P /' \
> +       '(-u --user)'{-u,--user=}'[username (default current user)]:user:_users' \
>         '(-l --list)'{-l,--list}'[list available chroots]' \
> -       '(-i --info)'{-i,--info}'[print detailed information about specified chroots]' \
> -       '--location[print location of specified  chroots]' \
> -       '--config[print configuration of specified  chroots]' \
> -       '(-p --preserve-environment)'{-p,--preserve-environment}'[preserve user environment within chroot]' \
> +       '(-i --info)'{-i,--info}'[show information about selected chroots]' \
> +       '--location[print location of selected chroots]' \
> +       '--config[dump configuration of selected chroots]' \
> +       '(-p --preserve-environment)'{-p,--preserve-environment}'[preserve user environment]' \
>         '(-q --quiet)'{-q,--quiet}'[quiet]' \
>         '(-v --verbose)'{-v,--verbose}'[verbose]' \
>         '(-V --version)'{-V,--version}'[version]' \
> -       '(-b --begin-session)'{-b,--begin-session}'[begin a session]' \
> -       '--recover-session}[recover an existing session]' \
> -       '(-e --end-session)'{-e,--end-session=}':session UUID:' \
> -       '(-f --force)'{-f,--force}'[force a session operation]' \
> +       '(-b --begin-session)'{-b,--begin-session}'[begin a session; returns a session ID]' \
> +       '--recover-session[recover an existing session]' \
> +       '(-e --end-session)'{-e,--end-session}'[end an existing session]' \
> +       '(-f --force)'{-f,--force}'[force operation]' \
>         '(-):command name: _command_names -e' \
>         '*::arguments: _normal' && return 0
>  
>  case "$state" in
>  	(chroot)
>  	_wanted tag expl 'chroot' \
> -	  compadd $(schroot -l)
> +	  compadd $(schroot -l -a)
>  	;;
> -
>  esac


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

* Re: Bug#390574: zsh: Updated completions for schroot and dchroot
       [not found]   ` <874punel7y.fsf@hardknott.home>
@ 2006-10-02  0:36     ` Clint Adams
       [not found]       ` <87sli6nyjc.fsf@hardknott.home>
  0 siblings, 1 reply; 3+ messages in thread
From: Clint Adams @ 2006-10-02  0:36 UTC (permalink / raw)
  To: Roger Leigh, 390574; +Cc: zsh-workers

> That's not quite right:
> 
> % echo ${(os:,:)${${${"$(dchroot -l)"#Available chroots:}/\[*\]/}//[
> ]/}}
> experimental  fake  sarge   sid-file  sid-file-source  sid-snap  sid-snap-source  testsnap  testsnap-source
> hardknott% dchroot -l
> Available chroots: experimental, fake, sarge [stable, sarge-backports], sid [unstable, unstable-sbuild], sid-block [sid-block], sid-file, sid-file-source, sid-snap, sid-snap-source, testsnap, testsnap-source
> 
> The output should be:
> experimental fake sarge stable sarge-backports sid unstable unstable-sbuild sid-block sid-file sid-file-source sid-snap sid-snap-source testsnap testsnap-source
> 
> i.e. the contents of the square brackets should not be eliminated.

How about ${(os:,:)${${${"$(cat /tmp/vakka)"#Available chroots: }// /}//[[\]]/,}}


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

* Re: Bug#390574: zsh: Updated completions for schroot and dchroot
       [not found]       ` <87sli6nyjc.fsf@hardknott.home>
@ 2006-10-03  6:14         ` Clint Adams
  0 siblings, 0 replies; 3+ messages in thread
From: Clint Adams @ 2006-10-03  6:14 UTC (permalink / raw)
  To: Roger Leigh, 390574; +Cc: zsh-workers

> That seems fine, except for the fact that "Available chroots" is
> translated, so everything up to and including the ':' needs removing.

Okay, committing this then

Index: _dchroot
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Debian/Command/_dchroot,v
retrieving revision 1.2
diff -u -r1.2 _dchroot
--- _dchroot	1 Oct 2006 21:57:05 -0000	1.2
+++ _dchroot	3 Oct 2006 06:14:06 -0000
@@ -22,7 +22,6 @@
 case "$state" in
 	(chroot)
 	_wanted tag expl 'chroot' \
-	compadd ${(os:,:)${${${"$(dchroot -l)"#Available chroots: }/\[*\]/}//[  
-]/}}
+	compadd ${(os:,:)${${${"$(dchroot -l )"#*: }// /}//[[\]]/,}}
 	;;
 esac
Index: _dchroot-dsa
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Debian/Command/_dchroot-dsa,v
retrieving revision 1.1
diff -u -r1.1 _dchroot-dsa
--- _dchroot-dsa	1 Oct 2006 21:57:05 -0000	1.1
+++ _dchroot-dsa	3 Oct 2006 06:14:06 -0000
@@ -21,7 +21,6 @@
 case "$state" in
 	(chroot)
 	_wanted tag expl 'chroot' \
-	compadd ${(os:,:)${${${"$(dchroot -l)"#Available chroots: }/\[*\]/}//[  
-]/}}
+        compadd ${(os:,:)${${${"$(dchroot -l )"#*: }// /}//[[\]]/,}}
 	;;
 esac


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

end of thread, other threads:[~2006-10-03  7:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20061001210027.13349.94075.reportbug@hardknott.home>
2006-10-01 21:49 ` Bug#390574: zsh: Updated completions for schroot and dchroot Clint Adams
     [not found]   ` <874punel7y.fsf@hardknott.home>
2006-10-02  0:36     ` Clint Adams
     [not found]       ` <87sli6nyjc.fsf@hardknott.home>
2006-10-03  6:14         ` Clint Adams

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