summaryrefslogtreecommitdiffstats
path: root/completions/rsync
diff options
context:
space:
mode:
Diffstat (limited to 'completions/rsync')
-rw-r--r--completions/rsync96
1 files changed, 52 insertions, 44 deletions
diff --git a/completions/rsync b/completions/rsync
index 0bf5389..f471b46 100644
--- a/completions/rsync
+++ b/completions/rsync
@@ -1,67 +1,75 @@
# bash completion for rsync -*- shell-script -*-
-_rsync()
+_comp_cmd_rsync()
{
- local cur prev words cword split
- _init_completion -s -n : || return
+ local cur prev words cword was_split comp_args
+ _comp_initialize -s -n : -- "$@" || return
+ local noargopts='!(-*|*[Te]*)'
+ # shellcheck disable=SC2254
case $prev in
- --config | --password-file | --include-from | --exclude-from | --files-from | \
- --log-file | --write-batch | --only-write-batch | --read-batch)
+ --config | --password-file | --include-from | --exclude-from | \
+ --files-from | --log-file | --write-batch | --only-write-batch | \
+ --read-batch)
compopt +o nospace
- _filedir
+ _comp_compgen_filedir
return
;;
- --temp-dir | --compare-dest | --backup-dir | --partial-dir | --copy-dest | \
- --link-dest | -!(-*)T)
+ --temp-dir | --compare-dest | --backup-dir | --partial-dir | \
+ --copy-dest | --link-dest | -${noargopts}T)
compopt +o nospace
- _filedir -d
+ _comp_compgen_filedir -d
return
;;
- --rsh | -!(-*)e)
+ --rsh | -${noargopts}e)
compopt +o nospace
- COMPREPLY=($(compgen -W 'rsh ssh' -- "$cur"))
+ _comp_compgen -- -W 'rsh ssh'
return
;;
--compress-level)
compopt +o nospace
- COMPREPLY=($(compgen -W '{1..9}' -- "$cur"))
+ _comp_compgen -- -W '{1..9}'
+ return
+ ;;
+ --info)
+ _comp_delimited , -W '
+ backup{,0}
+ copy{,0}
+ del{,0}
+ flist{,0,1,2}
+ misc{,0,1,2}
+ mount{,0}
+ name{,0,1,2}
+ nonreg{,0,1}
+ progress{,0,1,2}
+ remove{,0}
+ skip{,0,1,2}
+ stats{,0,1,2,3}
+ symsafe{,0}
+ all{,0,1,2,3,4}
+ none
+ help
+ '
return
;;
esac
- $split && return
+ [[ $was_split ]] && return
- _expand || return
+ _comp_expand || return
case $cur in
-*)
- COMPREPLY=($(compgen -W '--verbose --quiet --no-motd --checksum
- --archive --recursive --relative --no-implied-dirs
- --backup --backup-dir= --suffix= --update --inplace --append
- --append-verify --dirs --old-dirs --links --copy-links
- --copy-unsafe-links --safe-links --copy-dirlinks
- --keep-dirlinks --hard-links --perms --executability --chmod=
- --acls --xattrs --owner --group --devices --copy-devices
- --specials --times --omit-dir-times --super --fake-super
- --sparse --dry-run --whole-file --no-whole-file
- --one-file-system --block-size= --rsh= --rsync-path=
- --existing --ignore-existing --remove-source-files --delete
- --delete-before --delete-during --delete-delay --delete-after
- --delete-excluded --ignore-errors --force --max-delete=
- --max-size= --min-size= --partial --partial-dir=
- --delay-updates --prune-empty-dirs --numeric-ids --timeout=
- --contimeout= --ignore-times --size-only --modify-window=
- --temp-dir= --fuzzy --compare-dest= --copy-dest= --link-dest=
- --compress --compress-level= --skip-compress= --cvs-exclude
- --filter= --exclude= --exclude-from= --include= --include-from=
- --files-from= --from0 --protect-args --address= --port=
- --sockopts= --blocking-io --no-blocking-io --stats
- --8-bit-output --human-readable --progress --itemize-changes
- --out-format= --log-file= --log-file-format= --password-file=
- --list-only --bwlimit= --write-batch= --only-write-batch=
- --read-batch= --protocol= --iconv= --ipv4 --ipv6 --version
- --help --daemon --config= --no-detach' -- "$cur"))
+ local tmp
+ # Account for the fact that older rsync versions (before cba00be6,
+ # meaning before v3.2.0) contain the following unusual line in
+ # --help:
+ # "(-h) --help show this help (-h is --help only if used alone)"
+ _comp_compgen -Rv tmp help - <<<"$("$1" --help 2>&1 | command sed -e 's/^([^)]*)//')"
+
+ _comp_compgen -- -W '"${tmp[@]}"
+ --daemon --old-d{,irs}
+ --no-{blocking-io,detach,whole-file,inc-recursive,i-r}' -X '--no-OPTION'
[[ ${COMPREPLY-} == *= ]] || compopt +o nospace
;;
*:*)
@@ -73,14 +81,14 @@ _rsync()
break
fi
done
- [[ $shell == ssh ]] && _xfunc ssh _scp_remote_files
+ [[ $shell == ssh ]] && _comp_compgen -x scp remote_files
;;
*)
- _known_hosts_real -c -a -- "$cur"
- _xfunc ssh _scp_local_files
+ _comp_compgen_known_hosts -c -a -- "$cur"
+ _comp_compgen -ax scp local_files
;;
esac
} &&
- complete -F _rsync -o nospace rsync
+ complete -F _comp_cmd_rsync -o nospace rsync
# ex: filetype=sh