103 lines
3.3 KiB
Plaintext
Raw Normal View History

2009-05-17 21:57:13 +02:00
# bash completion for cpio
have cpio || return
2009-05-17 21:57:13 +02:00
_cpio_format()
{
2009-10-04 19:42:50 +02:00
COMPREPLY=( $( compgen -W 'bin odc newc crc tar ustar hpbin hpodc' -- "$cur" ) )
2009-05-17 21:57:13 +02:00
}
_cpio()
{
local cur prev words cword
_init_completion -n := || return
2009-05-17 21:57:13 +02:00
local split=false
2009-10-04 19:42:50 +02:00
_split_longopt && split=true
2009-05-21 10:40:09 +03:00
2009-10-04 19:42:50 +02:00
# --name value style option
case $prev in
-H|--format)
_cpio_format
return 0
;;
2009-11-22 09:30:22 +01:00
-E|-F|-I|--file|--pattern-file)
2009-10-04 19:42:50 +02:00
_filedir
return 0
;;
-R|--owner)
_usergroup
return 0
;;
--rsh-command)
compopt -o filenames
2009-10-04 19:42:50 +02:00
COMPREPLY=( $( compgen -c -- "$cur" ) )
return 0
;;
esac
2009-05-17 21:57:13 +02:00
2009-10-04 19:42:50 +02:00
$split && return 0
2009-05-17 21:57:13 +02:00
if [ $cword -eq 1 ]; then
COMPREPLY=( $( compgen -W '-o --create -i --extract -p --pass-through \
-? --help --license --usage --version' -- "$cur" ) )
2009-10-04 19:42:50 +02:00
else
case ${words[1]} in
-o|--create)
2009-10-04 19:42:50 +02:00
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-0 -a -c -v -A -B\
-L -V -C -H -M -O -F --file --format\
--message --null --reset-access-time\
--verbose --dot --append --block-size\
--dereference --io-size --quiet\
--force-local --rsh-command --help\
--version' -- "$cur" ) )
fi
;;
-i|--extract)
2009-10-04 19:42:50 +02:00
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-b -c -d -f -m -n -r\
-t -s -u -v -B -S -V -C -E -H -M -R -I\
-F --file --make-directories\
--nonmatching\
--preserve-modification-time\
--numeric-uid-gid --rename -t --list\
--swap-bytes --swap --dot\
--unconditional --verbose --block-size\
--swap-halfwords --io-size\
--pattern-file --format --owner\
--no-preserve-owner --message\
--force-local --no-absolute-filenames\
--sparse --only-verify-crc --quiet\
--rsh-command --help\
--to-stdout \
2009-10-04 19:42:50 +02:00
--version' -- "$cur" ) )
fi
;;
-p|--pass-through)
2009-10-04 19:42:50 +02:00
if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-0 -a -d -l -m -u -v\
-L -V -R --null --reset-access-time\
--make-directories --link --quiet\
--preserve-modification-time\
--unconditional --verbose --dot\
--dereference --owner\
--no-preserve-owner --sparse --help\
--version' -- "$cur" ) )
else
_filedir -d
fi
;;
esac
fi
2011-04-04 22:14:39 +03:00
} &&
complete -F _cpio cpio
# Local variables:
# mode: shell-script
2009-10-04 19:42:50 +02:00
# sh-basic-offset: 4
# sh-indent-comment: t
2009-10-04 19:42:50 +02:00
# indent-tabs-mode: nil
# End:
2009-10-04 19:42:50 +02:00
# ex: ts=4 sw=4 et filetype=sh