mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-09-10 12:40:58 +02:00
35879: fix for subcommands that don't have a second subcommand
This commit is contained in:
parent
8f8b82bc6c
commit
acf1fa6034
2 changed files with 137 additions and 133 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
2015-07-24 Oliver Kiddle <opk@zsh.org>
|
||||||
|
|
||||||
|
* 35879: Eric Cook: Completion/Linux/Command/_btrfs: fix for
|
||||||
|
subcommands that don't have a second subcommand
|
||||||
|
|
||||||
2015-07-24 Peter Stephenson <p.stephenson@samsung.com>
|
2015-07-24 Peter Stephenson <p.stephenson@samsung.com>
|
||||||
|
|
||||||
* 35883: Src/hist.c: Don't attempt to back up over history if
|
* 35883: Src/hist.c: Don't attempt to back up over history if
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#compdef btrfs
|
#compdef btrfs
|
||||||
# based on Btrfs v3.12+20131125
|
# based on Btrfs v3.12+20131125
|
||||||
|
|
||||||
local curcontext="$curcontext" curstate state line expl grp cmd ret=1
|
local curcontext="$curcontext" curstate state line expl grp cmd cont shift ret=1
|
||||||
local -a cmds_1 cmds_2 cmds_3 cmds_4 cmds_5 cmds_6 cmds_7 cmds_8 cmds_9 cmds_10
|
local -a cmds_1 cmds_2 cmds_3 cmds_4 cmds_5 cmds_6 cmds_7 cmds_8 cmds_9 cmds_10
|
||||||
local -a groups args
|
local -a groups args
|
||||||
|
|
||||||
|
@ -36,79 +36,32 @@ while (( $#state )); do
|
||||||
_wanted command-groups expl 'btrfs command group' compadd -a groups && ret=0
|
_wanted command-groups expl 'btrfs command group' compadd -a groups && ret=0
|
||||||
;;
|
;;
|
||||||
cmds)
|
cmds)
|
||||||
: $words
|
grp=${groups[(i)$words[2]*]}
|
||||||
local grp=${groups[(i)$words[2]*]}
|
|
||||||
: $grp
|
|
||||||
(( grp && grp <= 14 )) || return 1
|
(( grp && grp <= 14 )) || return 1
|
||||||
curcontext="${curcontext%:*:*}:$service-${groups[grp]}:"
|
cont=${groups[grp]}
|
||||||
case $grp in
|
curcontext="${curcontext%:*:*}:$service-${cont}:"
|
||||||
11)
|
if (( grp <= 10 )); then
|
||||||
# btrfs check
|
_wanted commands expl command compadd -a cmds_$grp && ret=0
|
||||||
args+=(
|
continue
|
||||||
{-s,--support}'[specify superblock]:superblock: _message "superblock"'
|
fi
|
||||||
'--repair[try to repair the filesystem]'
|
;&
|
||||||
'--init-csum-tree[create a new CRC tree]'
|
|
||||||
'--init-extent-tree[create a new extent tree]'
|
|
||||||
'1:path:_files -/'
|
|
||||||
)
|
|
||||||
;|
|
|
||||||
12)
|
|
||||||
# btrfs replace
|
|
||||||
args+=(
|
|
||||||
'-s[get snapshots]'
|
|
||||||
'-x[get extended attributes]'
|
|
||||||
'-v[verbose]'
|
|
||||||
'-i[ignore errors]'
|
|
||||||
'-o[overwrite]'
|
|
||||||
'-t[tree location]:tree:_message "tree location"'
|
|
||||||
'-f[filesystem location]:filesystem:_message "filesystem location"'
|
|
||||||
'-u[super mirror]:mirror:_message "super mirror"'
|
|
||||||
'-r[root objectid]:objectid:_message "root objectid"'
|
|
||||||
'-d[find dir]'
|
|
||||||
'-l[list tree roots]'
|
|
||||||
'--path-regex[restore matching filenames]:regex:_message "regex"'
|
|
||||||
'1:device:_files -/'
|
|
||||||
'2:path:_files -/'
|
|
||||||
)
|
|
||||||
;|
|
|
||||||
13)
|
|
||||||
# btrfs send
|
|
||||||
args+=(
|
|
||||||
'*-v[verbose mode]'
|
|
||||||
'-p[send incremental stream]:parent:_files -/'
|
|
||||||
'*-c[use snapshot as clone source]:clone:_files -/'
|
|
||||||
'-f[output file]:file:_files'
|
|
||||||
'1:subvol:_files -/'
|
|
||||||
)
|
|
||||||
;|
|
|
||||||
14)
|
|
||||||
# btrfs receive
|
|
||||||
args+=(
|
|
||||||
'*-v[verbose mode]'
|
|
||||||
'-f[input file]:file: _files'
|
|
||||||
'-e[terminate after <end cmd>]'
|
|
||||||
'1:mount:->mounts'
|
|
||||||
)
|
|
||||||
;|
|
|
||||||
<11-14>)
|
|
||||||
(( CURRENT-- )); shift words; curcontext="${curcontext%:*:*}:$service-${group[grp]}:"
|
|
||||||
_arguments -C "$args[@]" && ret=0
|
|
||||||
;;
|
|
||||||
<0-10>)
|
|
||||||
_wanted commands expl command compadd -a cmds_$grp && ret=0
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
;;
|
|
||||||
args)
|
args)
|
||||||
: $words
|
if [[ $curstate != cmds ]]; then
|
||||||
local grp=${groups[(i)$words[1]*]}
|
grp=${groups[(i)$words[1]*]}
|
||||||
(( grp && grp <= 15 )) || return 1
|
(( grp && grp <= 15 )) || return 1
|
||||||
local group=cmds_$grp
|
cont=${groups[grp]}
|
||||||
local cmd=${${(P)group}[(i)$words[2]*]}
|
if (( grp <= 10 )); then
|
||||||
(( cmd )) || return 1
|
local group=cmds_$grp
|
||||||
curcontext="${curcontext%:*:*}:$service-${groups[grp]}-${${(P)group}[cmd]}:"
|
local cmd=${${(P)group}[(i)$words[2]*]}
|
||||||
|
(( cmd )) || return 1
|
||||||
|
cont+=:${${(P)group}[cmd]}
|
||||||
|
else
|
||||||
|
shift=1
|
||||||
|
fi
|
||||||
|
curcontext="${curcontext%:*:*}:$service-${cont/:/-}:"
|
||||||
|
fi
|
||||||
args=( '(-)--help[print help information]' )
|
args=( '(-)--help[print help information]' )
|
||||||
case ${groups[grp]}:${${(P)group}[cmd]} in
|
case ${cont} in
|
||||||
filesystem:balance)
|
filesystem:balance)
|
||||||
if (( CURRENT == 3 )); then
|
if (( CURRENT == 3 )); then
|
||||||
state+=cmds
|
state+=cmds
|
||||||
|
@ -118,7 +71,7 @@ while (( $#state )); do
|
||||||
state+=args
|
state+=args
|
||||||
fi
|
fi
|
||||||
continue
|
continue
|
||||||
;;
|
;;
|
||||||
subvolume:create) args+=( '1:destination:->mounts' );;
|
subvolume:create) args+=( '1:destination:->mounts' );;
|
||||||
subvolume:delete) args+=( '1:subvolume:_files -/' );;
|
subvolume:delete) args+=( '1:subvolume:_files -/' );;
|
||||||
subvolume:snapshot)
|
subvolume:snapshot)
|
||||||
|
@ -128,7 +81,7 @@ while (( $#state )); do
|
||||||
'1:source directory:_files -/'
|
'1:source directory:_files -/'
|
||||||
'2:snapshot name or destination:_files -/'
|
'2:snapshot name or destination:_files -/'
|
||||||
)
|
)
|
||||||
;;
|
;;
|
||||||
subvolume:list)
|
subvolume:list)
|
||||||
args+=(
|
args+=(
|
||||||
'-p[include parent ID in output]'
|
'-p[include parent ID in output]'
|
||||||
|
@ -145,8 +98,8 @@ while (( $#state )); do
|
||||||
'-C[subvolume ogeneration is more or less than]:ogen: _guard "(|+|-)[0-9]#"'
|
'-C[subvolume ogeneration is more or less than]:ogen: _guard "(|+|-)[0-9]#"'
|
||||||
'--sort=-[list in order]:sort:_values -s "," sort rootid gen ogen path'
|
'--sort=-[list in order]:sort:_values -s "," sort rootid gen ogen path'
|
||||||
'1:path:->mounts'
|
'1:path:->mounts'
|
||||||
)
|
)
|
||||||
;;
|
;;
|
||||||
subvolume:set-default) args+=( '1:id:_guard "[0-9]#" id' '2:path:->mounts' );;
|
subvolume:set-default) args+=( '1:id:_guard "[0-9]#" id' '2:path:->mounts' );;
|
||||||
subvolume:get-default) args+=( '1:path:_files -/' );;
|
subvolume:get-default) args+=( '1:path:_files -/' );;
|
||||||
subvolume:find-new) args+=( '1:subvol:_files -/' '2:lastgen: _message "last gen"' );;
|
subvolume:find-new) args+=( '1:subvol:_files -/' '2:lastgen: _message "last gen"' );;
|
||||||
|
@ -161,16 +114,16 @@ while (( $#state )); do
|
||||||
'-l[defragment limited number of bytes]:length (bytes)'
|
'-l[defragment limited number of bytes]:length (bytes)'
|
||||||
'-t[defragment only files over a certain size]:minimum size (bytes)'
|
'-t[defragment only files over a certain size]:minimum size (bytes)'
|
||||||
'*:file:_files'
|
'*:file:_files'
|
||||||
)
|
)
|
||||||
;;
|
;;
|
||||||
filesystem:label) args+=( '1:device:_files -g "*(d)"' '2:label' );;
|
filesystem:label) args+=( '1:device:_files -g "*(d)"' '2:label' );;
|
||||||
filesystem:show)
|
filesystem:show)
|
||||||
args+=(
|
args+=(
|
||||||
'(1 -)'{-d,--all-devices}'[scan all devices in /dev]'
|
'(1 -)'{-d,--all-devices}'[scan all devices in /dev]'
|
||||||
'(1 -)'{-m,--mounted}'[show only mounted filesystems]'
|
'(1 -)'{-m,--mounted}'[show only mounted filesystems]'
|
||||||
'1: :_guard "^-*" uuid or label'
|
'1: :_guard "^-*" uuid or label'
|
||||||
)
|
)
|
||||||
;;
|
;;
|
||||||
device:(add|delete))
|
device:(add|delete))
|
||||||
args+=(
|
args+=(
|
||||||
'1:device:_files -g "*(d)"'
|
'1:device:_files -g "*(d)"'
|
||||||
|
@ -180,8 +133,8 @@ while (( $#state )); do
|
||||||
args+=(
|
args+=(
|
||||||
{-K,--nodiscard}'[do not perform discard]'
|
{-K,--nodiscard}'[do not perform discard]'
|
||||||
{-f,--force}'[force overwrite of existing filesystem]'
|
{-f,--force}'[force overwrite of existing filesystem]'
|
||||||
)
|
)
|
||||||
;;
|
;;
|
||||||
device:scan) args+=( '(1 -)--all-devices[scan all devices in /dev]' '1:device:_files -g "*(d)"' );;
|
device:scan) args+=( '(1 -)--all-devices[scan all devices in /dev]' '1:device:_files -g "*(d)"' );;
|
||||||
device:stats) args+=( "1:device or mountpoint:_files -g '*(d,/)'" '-z[reset stats when done]' );;
|
device:stats) args+=( "1:device or mountpoint:_files -g '*(d,/)'" '-z[reset stats when done]' );;
|
||||||
device:ready) args+=( '1:device: _files -g "*(d)"' );;
|
device:ready) args+=( '1:device: _files -g "*(d)"' );;
|
||||||
|
@ -195,9 +148,9 @@ while (( $#state )); do
|
||||||
'-c[set ioprio class]:class:(( 0\:none 1\:realtime 2\:best-effort 3\:idle))'
|
'-c[set ioprio class]:class:(( 0\:none 1\:realtime 2\:best-effort 3\:idle))'
|
||||||
'-n[set ioprio classdata]:classdata:(0 1 2 3 4 5 6 7)'
|
'-n[set ioprio classdata]:classdata:(0 1 2 3 4 5 6 7)'
|
||||||
'1:path or device:_files'
|
'1:path or device:_files'
|
||||||
)
|
)
|
||||||
[[ ${${(P)group}[cmd]} == start ]] && args+=( '-R[raw print mode]' )
|
[[ ${${(P)group}[cmd]} == start ]] && args+=( '-R[raw print mode]' )
|
||||||
;;
|
;;
|
||||||
scrub:cancel) args+=( '1:path or device' );;
|
scrub:cancel) args+=( '1:path or device' );;
|
||||||
scrub:status) args+=( '-d[separate statistics for each device]' '1:path or device:_files' );;
|
scrub:status) args+=( '-d[separate statistics for each device]' '1:path or device:_files' );;
|
||||||
balance:start)
|
balance:start)
|
||||||
|
@ -208,18 +161,18 @@ while (( $#state )); do
|
||||||
'-v[verbose mode]'
|
'-v[verbose mode]'
|
||||||
'-f[force reducing of metadata integrity]'
|
'-f[force reducing of metadata integrity]'
|
||||||
'1:path:_files -/'
|
'1:path:_files -/'
|
||||||
)
|
)
|
||||||
;;
|
;;
|
||||||
balance:status) args+=( '-v[verbose mode]' '2:path:_files -/' );;
|
balance:status) args+=( '-v[verbose mode]' '1:path:_files -/' );;
|
||||||
balance:(pause|cancel|resume)) args+=( '2:path:_files -/' );;
|
balance:(pause|cancel|resume)) args+=( '1:path:_files -/' );;
|
||||||
quota:(enable|disable)) args+=( '1:path:_files -/' );;
|
quota:(enable|disable)) args+=( '1:path:_files -/' );;
|
||||||
quota:rescan)
|
quota:rescan)
|
||||||
args+=(
|
args+=(
|
||||||
'-s[show status of currently running rescan]'
|
'-s[show status of currently running rescan]'
|
||||||
'-w[wait for rescan to finish]'
|
'-w[wait for rescan to finish]'
|
||||||
'1:path:_files -/'
|
'1:path:_files -/'
|
||||||
)
|
)
|
||||||
;;
|
;;
|
||||||
qgroup:(assign|remove)) args+=( '1:source path:_files -/'
|
qgroup:(assign|remove)) args+=( '1:source path:_files -/'
|
||||||
'2:destination path:_files -/' '3:path:_files -/' );;
|
'2:destination path:_files -/' '3:path:_files -/' );;
|
||||||
qgroup:(create|destroy)) args+=( '1:qgroupid:' '2:path:_files -/' );;
|
qgroup:(create|destroy)) args+=( '1:qgroupid:' '2:path:_files -/' );;
|
||||||
|
@ -234,17 +187,17 @@ while (( $#state )); do
|
||||||
'--sort=-[sort qgroups]:sort:_values -s , sort \
|
'--sort=-[sort qgroups]:sort:_values -s , sort \
|
||||||
qgroupid rfer excl max_rfer max_excl'
|
qgroupid rfer excl max_rfer max_excl'
|
||||||
'1:path:_files -/'
|
'1:path:_files -/'
|
||||||
)
|
)
|
||||||
;;
|
;;
|
||||||
qgroup:limit)
|
qgroup:limit)
|
||||||
args+=(
|
args+=(
|
||||||
'-c[limit amount of data after compression]'
|
'-c[limit amount of data after compression]'
|
||||||
'-e[limit space exclusively to qgroup]'
|
'-e[limit space exclusively to qgroup]'
|
||||||
':size or none: _message "size or none"'
|
':size or none: _message "size or none"'
|
||||||
':qgroup id or path:_files -/'
|
':qgroup id or path:_files -/'
|
||||||
':path:_files -/'
|
':path:_files -/'
|
||||||
)
|
)
|
||||||
;;
|
;;
|
||||||
replace:start)
|
replace:start)
|
||||||
args+=(
|
args+=(
|
||||||
'-r[read from <srcdev> only]:srcdev:_files'
|
'-r[read from <srcdev> only]:srcdev:_files'
|
||||||
|
@ -253,8 +206,8 @@ while (( $#state )); do
|
||||||
':srcdev or devid:_files'
|
':srcdev or devid:_files'
|
||||||
':target:_files'
|
':target:_files'
|
||||||
':path:->mounts'
|
':path:->mounts'
|
||||||
)
|
)
|
||||||
;;
|
;;
|
||||||
replace:status) args+=( '-1[print once]' ':path:->mounts' );;
|
replace:status) args+=( '-1[print once]' ':path:->mounts' );;
|
||||||
replace:cancel) args+=( ':path:->mounts' );;
|
replace:cancel) args+=( ':path:->mounts' );;
|
||||||
inspect*:inode*) args+=( '-v[verbose mode]' '1:inode:_files' '2:path:_files -/' );;
|
inspect*:inode*) args+=( '-v[verbose mode]' '1:inode:_files' '2:path:_files -/' );;
|
||||||
|
@ -266,28 +219,74 @@ while (( $#state )); do
|
||||||
'-s[buffer size]:buffer size:'
|
'-s[buffer size]:buffer size:'
|
||||||
'1:logical address:_files'
|
'1:logical address:_files'
|
||||||
'2:filesystem path:_files -/'
|
'2:filesystem path:_files -/'
|
||||||
)
|
)
|
||||||
;;
|
;;
|
||||||
inspect*:rootid) args+=( '1:path:_files -/' );;
|
inspect*:rootid) args+=( '1:path:_files -/' );;
|
||||||
rescue:(chunk|super)-recover)
|
rescue:(chunk|super)-recover)
|
||||||
args+=(
|
args+=(
|
||||||
'-y[assume yes to every question]'
|
'-y[assume yes to every question]'
|
||||||
'-v[verbose mode]'
|
'-v[verbose mode]'
|
||||||
)
|
)
|
||||||
[[ ${${(P)group}[cmd]} == chunk-recover ]] && args+=('-h[display help]')
|
[[ ${${(P)group}[cmd]} == chunk-recover ]] && args+=('-h[display help]')
|
||||||
;;
|
;;
|
||||||
subvolume:get-default) ;&
|
subvolume:get-default) ;&
|
||||||
*:sync) ;&
|
*:sync) ;&
|
||||||
*:df) args+=( '1:path:->mounts' );;
|
*:df) args+=( '1:path:->mounts' );;
|
||||||
|
check)
|
||||||
|
args+=(
|
||||||
|
{-s,--support}'[specify superblock]:superblock'
|
||||||
|
'--repair[try to repair the filesystem]'
|
||||||
|
'--init-csum-tree[create a new CRC tree]'
|
||||||
|
'--init-extent-tree[create a new extent tree]'
|
||||||
|
'1:path:_files -/'
|
||||||
|
)
|
||||||
|
;;
|
||||||
|
restore)
|
||||||
|
args+=(
|
||||||
|
'-s[get snapshots]'
|
||||||
|
'-x[get extended attributes]'
|
||||||
|
'-v[verbose]'
|
||||||
|
'-i[ignore errors]'
|
||||||
|
'-o[overwrite]'
|
||||||
|
'-t[tree location]:tree'
|
||||||
|
'-f[filesystem location]:filesystem'
|
||||||
|
'-u[super mirror]:mirror'
|
||||||
|
'-r[root objectid]:objectid'
|
||||||
|
'-d[find dir]'
|
||||||
|
'-l[list tree roots]'
|
||||||
|
'--path-regex[restore matching filenames]:regex'
|
||||||
|
'1:device:_files -/'
|
||||||
|
'2:path:_files -/'
|
||||||
|
)
|
||||||
|
;;
|
||||||
|
send)
|
||||||
|
args+=(
|
||||||
|
'*-v[verbose mode]'
|
||||||
|
'-p[send incremental stream]:parent:_files -/'
|
||||||
|
'*-c[use snapshot as clone source]:clone:_files -/'
|
||||||
|
'-f[output file]:file:_files'
|
||||||
|
'1:subvolume:_files -/'
|
||||||
|
)
|
||||||
|
;;
|
||||||
|
receive)
|
||||||
|
args+=(
|
||||||
|
'*-v[verbose mode]'
|
||||||
|
'-f[input file]:file: _files'
|
||||||
|
'-e[terminate after <end cmd>]'
|
||||||
|
'1:mount:->mounts'
|
||||||
|
)
|
||||||
|
;;
|
||||||
*) args+=( '*: :_default' );; # fallback for unknown subcommands
|
*) args+=( '*: :_default' );; # fallback for unknown subcommands
|
||||||
esac
|
esac
|
||||||
shift words
|
if ! (( shift )); then
|
||||||
(( CURRENT-- ))
|
shift words
|
||||||
|
(( CURRENT-- ))
|
||||||
|
fi
|
||||||
_arguments -C "$args[@]" && ret=0
|
_arguments -C "$args[@]" && ret=0
|
||||||
;;
|
;;
|
||||||
mounts)
|
mounts)
|
||||||
_wanted mount-points expl 'mount point' compadd \
|
_wanted mount-points expl 'mount point' compadd \
|
||||||
${${${(M)${(f)"$(</etc/mtab)"}:#*btrfs*}#* }%% *} && ret=0
|
${${${(M)${(f)"$(</etc/mtab)"}:#*btrfs*}#* }%% *} && ret=0
|
||||||
;;
|
;;
|
||||||
filters)
|
filters)
|
||||||
state=()
|
state=()
|
||||||
|
|
Loading…
Reference in a new issue