1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-10-03 08:11:03 +02:00

Merge 17080,17076,17075,17074,16461,16434,16437,16258,16247,16253

This commit is contained in:
Andrey Borzenkov 2002-05-08 15:55:36 +00:00
parent 6d73a3b843
commit ae5ac5edea
12 changed files with 344 additions and 12 deletions

View file

@ -1,3 +1,21 @@
2002-05-08 Andrej Borsenkow <bor@zsh.org>
* 17080: Doc/Zsh/compsys.yo: clarify tag-order style usage
* 17076: Completion/Redhat/Command/.distfiles,
Completion/Redhat/Command/_service, Completion/Unix/Command/_chkconfig,
Completion/Unix/Command/_init_d, Completion/Unix/Type/.distfiles,
Completion/Unix/Type/_services: use new helper _services to complete
init/xinetd services; make chkconfig use it; completion of
service command
* 17075: Completion/Mandrake/Command/_urpmi: _urpmi
completion update
* 17074: Completion/Linux/Command/.distfiles,
Completion/Linux/Command/_mondo, Src/Zle/complete.mdd:
mondoarchive completion (with typo correction from Bart)
2002-05-03 Oliver Kiddle <opk@zsh.org>
* 17072; based on 17066 (Danek Duvall):
@ -280,6 +298,16 @@
* 16449: Completion/Unix/Command/_chkconfig: new completion for
both the IRIX and RedHat chkconfig commands
2002-01-14 Andrej Borsenkow <bor@zsh.org>
* 16443: Completion/Mandrake/Command/_urpmi: fix
urpmi.addmedia --distrib. Set cache policy on just the first call.
2002-01-13 Andrej Borsenkow <bor@zsh.org>
* 16437: Completion/Mandrake/Command/_urpmi: adapt
to new urpmi version in cooker
2002-01-03 Oliver Kiddle <opk@zsh.org>
* 16396: Completion/Unix/Command/_chown: fix argument handling bugs
@ -390,6 +418,11 @@
* 16264: Completion/Debian/Command/_dput:
Use parameter expansion instead of grep and sed.
2001-11-16 Chmouel Boudjnah <chmouel@mandrakesoft.com>
* 16258: Completion/Mandrake/Command/_urpmi:
Fix typo in _urpmi for urpmi.addmedia.
2001-11-15 Clint Adams <clint@zsh.org>
* unposted: Functions/Prompts/prompt_clint_setup:
@ -399,6 +432,11 @@
Completion/Debian/Command/_dput: completion for
dput as contributed by Tollef Fog Heen <tollef@add.no>.
2001-11-15 Chmouel Boudjnah <chmouel@mandrakesoft.com>
* 16253: Src/Zle/complete.mdd: Add Mandrake completion directory to
install.
2001-11-15 Peter Stephenson <pws@csr.com>
* 15288, 15432, 15585: Doc/Zsh/contrib.yo,
@ -410,6 +448,12 @@
Functions/Zle/bash-backward-kill-word:
Zle widgets with bash-style word delimiting.
2001-11-14 Andrej Borsenkow <bor@zsh.org>
* 16247: Completion/Mandrake/Command/_urpmi: completion
for Mandrake urpmi command suit.
2001-11-06 Oliver Kiddle <opk@zsh.org>
* unposted: Functions/Misc/mere: fix for IRIX

View file

@ -0,0 +1,4 @@
DISTFILES_SRC='
.distfiles
_mondo
'

View file

@ -0,0 +1,53 @@
#compdef mondoarchive
local context state line expl ret=1
typeset -A opt_args
_arguments \
"(-V)-O[create backup]" \
"(-O)-V[verify backup]" \
"(-c -C -i -n -w)-c[use CD-R as backup media]:CD-R burn speed: " \
"(-c -C -i -n -w)-C[use CD-R as streaming device (experimental)]:CD-R burn speed: " \
"(-c -C -i -n -w)-i[use ISO image as backup media]" \
"(-c -C -i -n -w)-n[use NFS mountpoint as backup media]:NFS mountpoint: " \
"(-c -C -i -n -w)-w[use CD-RW as backup media]:CD-RW burn speed: " \
"-D[differential backup]" \
"-E[exclude path(s) from backup]:paths to exclude from backup:->quoted_path" \
"-I[path(s) to backup]:paths to inlcude in backup:->quoted_path" \
"-d[backup device]:backup device: " \
"-g[run in fullscreen mode]" \
"-k[path to kernel]:path to kernel:->kernel_or_magic" \
"-m[manual eject]" \
"-s[media size]:media size]: " \
"-x[non-linux partition]:non-linux partition:_files -g '*(%b)'" \
"(-1 -2 -3 -4 -5 -6 -7 -8 -9)-"{1,2,3,4,5,6,7,8,9}"[compression level]" \
"-A[post ISO-creation command]:pre ISO-creation command: " \
"-B[pre iSO-creation command]:post ISO-creation command: " \
"-F[do not create floppy]" \
"-H[create autorestore image]" \
"-L[use lzo instead of bzip2]" \
"-P[post-nuke tarball]:post-nuke tarball:_files -g '*.(#i)(tar.gz|tgz)'" \
"-S[scratch directory]:scratch directory:_files -/" \
"-T[temporary directory]:temporary directory:_files -/" \
"-f[device with MBR]:device with MBR:_files -g '*(%b)'" \
"-l[bootloader type]:bootloader type:(GRUB LILO)" \
&& ret=0
case $state in
quoted_path )
local suf="/ \t\n"
[[ -n $compstate[quote] ]] && { suf="$compstate[quote]$suf"; compset -q; }
_files -r $suf && ret=0
;;
kernel_or_magic )
_tags kernel magic
while _tags; do
_requested magic expl "keywords" \
compadd -- FAILSAFE && ret=0
_requested kernel expl "path to kernel image" \
_files && ret=0
done
;;
esac
return $ret

View file

@ -0,0 +1,4 @@
DISTFILES_SRC='
.distfiles
_urpmi
'

View file

@ -0,0 +1,177 @@
#compdef urpme urpmi urpmi.addmedia urpmi.removemedia urpmi.update urpmq
_urpmi_cache_policy() {
local -a synthesis
local i
synthesis=(/var/lib/urpmi/synthesis.*)
for i in $synthesis; do
[[ -e "$1" && -e "$i" && "$1" -nt "$i" ]] && return 1
done
return 0
}
_urpmi_media() {
local source media brace expl
local -a all_sources
[[ -f /etc/urpmi/urpmi.cfg ]] || return 1
while read source media brace; do
[[ "$brace" != "{" ]] && continue
all_sources=("$all_sources[@]" $source)
done < /etc/urpmi/urpmi.cfg
_values -s , 'urpmi media' "$all_sources[@]"
}
_urpmi_rpms() {
local pkg ret=1 expl
_tags rpms files
while _tags; do
if _requested rpms expl 'urpmi RPMs'; then
local -a synthesis pkgs
synthesis=(/var/lib/urpmi/synthesis.*(N))
if [[ $#synthesis -gt 0 ]]; then
if _cache_invalid _urpmi_rpms || ! _retrieve_cache _urpmi_rpms; then
pkgs=($(zcat $synthesis | \
grep @info@ | cut -d @ -f 3 | sed -e 's/\.[^.]*$//'))
_store_cache _urpmi_rpms pkgs
fi
compadd "$expl[@]" -a pkgs && ret=0
fi
fi
_requested files expl '(S)RPM files' \
_files -g '*.(#i)rpm' && ret=0
done
return $ret
}
_urpmi_media_url() {
local expl ret=1
if compset -P file:// || compset -P removable://; then
_files "$@" -W / -/ && ret=0
elif [[ -prefix '(ftp|http)://' ]]; then
_urls "$@" && ret=0
else
_wanted mediatype expl 'type of media' \
compadd "$@" -- file:// http:// ftp:// removable:// && ret=0
fi
return $ret
}
_urpme_package() {
local -a _rpms
_rpms=( $(_call_program packages rpm -qa 2>/dev/null) )
compadd "$@" -a -- _rpms
}
_urpmi() {
local state context line ret=1
typeset -A opt_args
case "$service" in
urpme )
_arguments -A '-*' \
"--auto[do not ask any question]" \
"-a[find all matches]" \
": :_urpme_package"
;;
urpmi.addmedia )
_arguments -A '-*' \
"(--wget)--curl[use curl to retrieve distant files]" \
"(:)--distrib[automatically create all media from an installation medium]:media URL:_urpmi_media_url" \
"--update[mark as update media]" \
"(--curl)--wget[use wget to retrieve distant files]" \
"-c[clean headers cache directory]" \
"-f[force generation of hdlist files]" \
"-h[try to find and use synthesis or hdlist file]" \
"(--distrib):name of media: " \
"(--distrib):media URL:_urpmi_media_url" \
"(--distrib): :(with)" \
"(--distrib):relative path to hdlist file: " \
&& ret=0
;;
urpmi.removemedia )
_arguments -A '-*' \
"(:)-a[select all media]" \
"(-a)"{,\*}": :_urpmi_media" \
&& ret=0
;;
urpmi.update )
_arguments -A '-*' \
"(--wget)--curl[use curl to retrieve distant files]" \
"(--curl)--wget[use wget to retrieve distant files]" \
"(:)-a[select all non-removable media]" \
"-c[clean /var/cache/urpmi/headers on exit]" \
"-d[force complete computation of depslist.ordered file]" \
"*-f[force generation of hdlist files]" \
"(-a)"{,\*}": :_urpmi_media" \
&& ret=0
;;
urpmi )
_arguments -A '-*' \
"(: -)--help[print usage information]" \
"(--help)--allow-medium-change[allow change of removable media]" \
"(--help)--auto[do not ask any questions]" \
"(--help)--auto-select[select the packages to update]" \
"(--help -X)--best-output[automatically select text or X interface]" \
"(--help)--complete[use parsehdlist server to complete selection]" \
"(--help --wget)--curl[use curl to retrieve distant files]" \
"(--help)--force[proceed even when some packages do not exist]" \
"(--help --fuzzy -z)"{--fuzzy,-y}"[return all matches even if exact match exists]" \
"(--help)--media[use only the media listed by comma]: :_urpmi_media" \
"(--help)--noclean[do not clean RPM cache]" \
"(--help --src -s)"{--src,-s}"[next package is source package]" \
"(--help)--update[use only update media]" \
"(--help --curl)--wget[use wget to retrieve distant files]" \
"(--help)-a[select all packages matching command line]" \
"(--help -m -M)-m[choose minimum closure of requires (default)]" \
"(--help -m -M)-M[choose maximum closure of requires]" \
"(--help)-P[do not search in provides]" \
"(--help -q -v)-q[be quiet]" \
"(--help -q -v)-v[verbose mode]" \
"(--help --best-output)-X[use X interface]" \
"(--help)"{,\*}": :_urpmi_rpms" \
&& ret=0
;;
urpmq )
_arguments -A '-*' \
"(--help -h)--auto-select[automatically select packages for upgrading the system]" \
"(--help -h)--force[ignore non-existent packages]" \
"(--help -h --fuzzy -z)"{--fuzzy,-y}"[return all matches even if exact match exists]" \
"(--help -h)--headers[extract headers for package listed from urpmi db to stdout]" \
"(--help -h)--media[use only the media listed by comma]: :_urpmi_media" \
"(--help -h)--sources[show full path to package file]" \
"(--help -h --src -s)"{--src,-s}"[next package is source package]" \
"(--help -h)--update[use only update media]" \
"(--help -h -c -p -P)-c[choose complete method for resolving requires closure]" \
"(--help -h)-d[show package depndencies]" \
"(--help -h)-f[print version, release and arch with name]" \
"(--help -h)-g[print groups too with name]" \
"(--help -h -c -p -P)-p[allow search in provides to find package]" \
"(--help -h -c -p -P)-P[do not search in provides to find package]" \
"(--help -h)-r[print version and release too with name]" \
"(--help -h)-u[remove package if a better version is already installed]" \
"(--help -h)-v[verbose mode]" \
"(--help -h)*:urpmi package name: " \
&& ret=0
;;
esac
return $ret
}
local update_policy
zstyle -s ":completion:*:*:urpmi:*" cache-policy update_policy
if [[ -z "$update_policy" ]]; then
zstyle ":completion:*:*:urpmi:*" cache-policy _urpmi_cache_policy
fi
_urpmi "$@"

View file

@ -0,0 +1,5 @@
DISTFILES_SRC='
.distfiles
_rpm
_service
'

View file

@ -0,0 +1,22 @@
#compdef service
# *:: for last argument looks more like a hack but it is
# the simplest way known to me to reset $words and keep
# _sub_command happy
# we are interested in init service only
local ctx="${curcontext/%[^:]#:[^:]#/argument-1:}"
zstyle -T ":completion:$ctx" tag-order && \
zstyle ":completion:$ctx" tag-order init -
_arguments -s \
'(-d --debug)'{-d,--debug}'[turn debugging on]' \
'(- :)'{-h,--help}'[print usage]' \
'(- :)'{-v,--version}'[print version]' \
'(-)'{-f,--full-restart}'[restart service]' \
'(- :)'{-R,--full-restart-all}'[restart all services]' \
'(- :)'{-s,--status-all}'[print status of all services]' \
':service name:_services' \
'*::service argument: _init_d'

View file

@ -9,13 +9,8 @@ linux*)
'(-)--level[specify runlevels to apply to]:-:_values -s "" "run levels" 1 2 3 4 5 6 7' \
'(- 2)--add[add new service]' \
'(- 2)--del[remove service from chkconfig management]' \
'1:service name:->services' \
'1:service name:_services' \
'2:state:(on off reset)' && ret=0
if [[ -n "$state" ]]; then
_wanted services expl 'system service' \
compadd ${${${(f)"$($words[1] --list)"}%%[ :]*}##$'\t'*} && ret=0
fi
;;
irix*)
_arguments -C \

View file

@ -1,21 +1,24 @@
#compdef -P */(init|rc[0-9S]#).d/*
local magic cmds what
local magic cmds what script
# This should probably be system specific...
script=$words[1]
[[ $script = */* ]] || script=/etc/init.d/$script
# If the file starts with `#!' we hope that this is a shell script
# and get lines looking like <space>foo|bar) with the words in $what.
what='(st(art|op|atus)|(force-|)re(start|load)|debug_(up|down)|dump(|_stats)|add|delete|clean|list)'
[[ -f $words[1] ]] && read -u0k 2 magic < $words[1] && [[ $magic = '#!' ]] &&
cmds=( ${${(j:|:s:|:)${(M)${(f)"$(< $words[1])"}:#[[:blank:]]#\'#${~what}(\|${~what})#\'#\)*}}//[^a-z_-]} )
read -u0k 2 magic < $script && [[ $magic = '#!' ]] &&
cmds=( ${${(j:|:s:|:)${(M)${(f)"$(< $script)"}:#[[:blank:]]#(\'|)${~what}(\|{~what})#(\'|)\)}}//[^a-z_]} )
# This would be the pattern to use every line of the form <space>foo).
# Some people say this might match too many lines...
#
# cmds=( ${${(j:|:s:|:)${(M)${(f)"$(< $words[1])"}:#[[:blank:]]#(\'|)[a-z_|]##(\'|)\)}}//[^a-z_]} )
# cmds=( ${${(j:|:s:|:)${(M)${(f)"$(< $script)"}:#[[:blank:]]#(\'|)[a-z_|]##\'|)\)}}//[^a-z_]} )
(( $#cmds )) || zstyle -a ":completion:${curcontext}:commands" commands cmds ||
cmds=(start stop)

View file

@ -8,4 +8,5 @@ _domains _path_files _ps _user_at_host
_files _pdf _pspdf _users
_groups _perl_basepods _signals _users_on
_hosts _perl_builtin_funcs _tar_archive _net_interfaces
_services
'

View file

@ -0,0 +1,23 @@
#autoload
local -a inits xinetds alls
local expl ret=1
if chkconfig --list > /dev/null 2>&1; then
alls=( ${(f)"$(LANGUAGE=C LANG=C LC_ALL=C chkconfig --list)"} )
inits=( ${${${alls[1,(r)xinetd based*]}[1,-2]}/%[[:space:]]*/} )
xinetds=( ${${${${alls[(r)xinetd based*,-1]}[2,-1]}/#[[:space:]]#}/%:*} )
else
inits=( /etc/init.d/*(:t) )
fi
_tags init xinetd
while _tags; do
_requested init expl 'init services' \
compadd -a inits && ret=0
_requested xinetd expl 'xinetd services' \
compadd -a xinetds && ret=0
done
return $ret

View file

@ -1,4 +1,7 @@
name=zsh/complete
link=either
load=yes
functions='Completion/comp* Completion/AIX/*/* Completion/BSD/*/* Completion/Base/*/* Completion/Debian/*/* Completion/Linux/*/* Completion/Mandrake/*/* Completion/Redhat/*/* Completion/Unix/*/* Completion/X/*/* Completion/Zsh/*/*'
moddeps="zsh/zle"
@ -6,8 +9,6 @@ autobins="compadd compset"
autoprefixconds="prefix suffix between after"
autoparams="compmatchers"
headers="comp.h"
objects="complete.o compcore.o compmatch.o compresult.o"