From 6aa15f57fd5bee298c8320dab19d167dac3d46ed Mon Sep 17 00:00:00 2001 From: Oliver Kiddle Date: Wed, 22 Nov 2023 00:07:37 +0100 Subject: 52315: completion options update --- Completion/Unix/Command/_rsync | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'Completion/Unix/Command/_rsync') diff --git a/Completion/Unix/Command/_rsync b/Completion/Unix/Command/_rsync index eb906e974..c65266dbd 100644 --- a/Completion/Unix/Command/_rsync +++ b/Completion/Unix/Command/_rsync @@ -141,8 +141,9 @@ _rsync() { '(-X --xattrs)'{-X,--xattrs}'[preserve extended attributes]' \ '--fake-super[use xattrs to save all file attributes]' \ '(-d --dirs)'{-d,--dirs}'[transfer directories without recursing]' \ - {--no-d,--no-dirs}'[turn off --dirs]' \ - "--mkpath[create the destination's path component]" \ + '(--no-d --no-dirs)'{--no-d,--no-dirs}'[turn off --dirs]' \ + '(--old-dirs --old-d)'{--old-dirs,--old-d}'[work like --dirs when talking to old rsync]' \ + "--mkpath[create destination's missing path components]" \ '(-l --links)'{-l,--links}'[copy symlinks as symlinks]' \ {--no-l,--no-links}'[turn off --links]' \ '(-L --copy-links)'{-L,--copy-links}'[transform symlinks into referent file/dir]' \ @@ -161,8 +162,10 @@ _rsync() { '(-g --group)'{-g,--group}'[preserve group]' \ {--no-g,--no-group}'[turn off --group]' \ '(--devices --specials)-D[same as --devices --specials]' \ - '(-D)--devices[preserve devices]' \ + '(-D --copy-devices --write-devices)--devices[preserve devices]' \ '--no-devices[turn off --devices]' \ + '(-D --devices)--copy-devices[copy device contents as a regular file]' \ + '(-D --devices)--write-devices[write to devices as files (implies --inplace)]' \ '(-D)--specials[preserve special files]' \ '--no-specials[turn off --specials]' \ '--no-D[turn off --devices and --specials]' \ @@ -179,7 +182,7 @@ _rsync() { '(-n --dry-run)'{-n,--dry-run}'[show what would have been transferred]' \ '(-W --whole-file)'{-W,--whole-file}'[copy files whole (without delta-transfer algorithm)]' \ {--no-W,--no-whole-file}'[turn off --whole-file]' \ - '(--cc --checksum-choice)'{--cc,--checksum-choice}'=[choose the checksum algorithms]:algorithm:_sequence -n 2 compadd - auto md4 md5 none' \ + '(--cc --checksum-choice)'{--cc,--checksum-choice}'=[choose the checksum algorithms]:algorithm:_sequence -n 2 compadd - auto xxh128 xxh3 xxh64 xxhash md4 md5 sha1 none' \ '(-x --one-file-system)'{-x,--one-file-system}"[don't cross filesystem boundaries]" \ '(-B --block-size)'{-B+,--block-size=}'[force a fixed checksum block-size]: :_numbers -f -u bytes -d 1g "block size" B K M G T P' \ '(-e --rsh)'{-e+,--rsh=}'[specify the remote shell to use]:remote-shell command:(rsh ssh)' \ @@ -233,7 +236,8 @@ _rsync() { '*--include=[do not exclude files matching pattern]:pattern' \ '--files-from=[read list of source-file names from specified file]:file:_files' \ '(-0 --from0)'{-0,--from0}'[all *-from file lists are delimited by nulls]' \ - '(-s --protect-args)'{-s,--protect-args}'[no space-splitting; only wildcard special-chars]' \ + '(-s --secluded-args)'{-s,--secluded-args}'[use the protocol to safely send arguments]' \ + "--trust-sender[trust the remote sender's file list]" \ '--copy-as=[specify user & optional group for the copy]:user:_rsync_users_groups' \ '--version[print version number]' \ '*'{-h,--human-readable}'[output numbers in a human-readable format]' \ @@ -251,6 +255,7 @@ _rsync() { '--list-only[list the files instead of copying them]' \ '--stop-after=[stop copying after specified time has elapsed]:time (minutes)' \ '--stop-at=[stop copying when specified point in time is reached]:date/time (YYYY-MM-DDTHH\:MM):_dates -F -S "T"' \ + '--fsync[fsync every written file]' \ '(--only-write-batch)--write-batch=[write a batched update to the specified file]:file:_files' \ '(--write-batch)--only-write-batch=[like --write-batch but w/o updating destination]:file:_files' \ '--protocol=[force an older protocol version to be used]:number' \ -- cgit v1.2.3 From 5cb32ec5ab1eafdad62500e7e6bdada2c3205a59 Mon Sep 17 00:00:00 2001 From: Eric Cook Date: Sat, 3 Aug 2024 20:07:51 -0400 Subject: 52989: _rsync: support rsync 3.2.4+ remote filename handling. --- ChangeLog | 6 ++++++ Completion/Unix/Command/_rsync | 10 +++++++++- Completion/Unix/Type/_remote_files | 20 +++++++++++++++----- 3 files changed, 30 insertions(+), 6 deletions(-) (limited to 'Completion/Unix/Command/_rsync') diff --git a/ChangeLog b/ChangeLog index 22ccce77a..f47690476 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2024-08-03 Eric Cook + + * 52989: Completion/Unix/Command/_rsync, + Completion/Unix/Type/_remote_files: support rsync 3.2.4+ remote + filename handling. + 2024-07-28 Peter Stephenson * 52999: Franklin Yu (adapted): Src/init.c: Import OLDPWD from diff --git a/Completion/Unix/Command/_rsync b/Completion/Unix/Command/_rsync index c65266dbd..81d25a3f4 100644 --- a/Completion/Unix/Command/_rsync +++ b/Completion/Unix/Command/_rsync @@ -60,7 +60,14 @@ elif compset -P 1 '*::' || compset -P 1 'rsync://*/'; then elif compset -P 'rsync://'; then _rsync_user_or_host / "$@" elif compset -P 1 '*:'; then - _remote_files -- ssh + if [[ -v opt_args[(i)client---old-args] || $RSYNC_OLD_ARGS = 1 ]]; then + _remote_files -- ssh + else + # the 3.2.4+ way that rsync handles filenames does not protect *, ? and [] + # so those characters still need to be escaped to prevent being treated as + # a pattern in the remote shell. + _remote_files -Q '[][*?]' -- ssh + fi else _rsync_user_or_host : "$@" fi @@ -236,6 +243,7 @@ _rsync() { '*--include=[do not exclude files matching pattern]:pattern' \ '--files-from=[read list of source-file names from specified file]:file:_files' \ '(-0 --from0)'{-0,--from0}'[all *-from file lists are delimited by nulls]' \ + '--old-args[disable the modern arg-protection idiom]' \ '(-s --secluded-args)'{-s,--secluded-args}'[use the protocol to safely send arguments]' \ "--trust-sender[trust the remote sender's file list]" \ '--copy-as=[specify user & optional group for the copy]:user:_rsync_users_groups' \ diff --git a/Completion/Unix/Type/_remote_files b/Completion/Unix/Type/_remote_files index 93e1b7f43..15c20e5c1 100644 --- a/Completion/Unix/Type/_remote_files +++ b/Completion/Unix/Type/_remote_files @@ -11,6 +11,8 @@ # - -g: specify a pattern to match against files # p, = and * glob qualifiers supported # - -h: specify the remote host, default is ${IPREFIX%:} +# - -Q: specify a pattern of characters to escape in the returned filenames, +# instead of shell metacharacters that ${(q)name} does # - -W: specify the parent directory to list files from, # default is the home directory # @@ -31,14 +33,14 @@ # There should be coloring based on all the different ls -F classifiers. -local expl rempat remfiles remdispf remdispd args cmd suf ret=1 +local expl rempat remfiles remdispf{,q} remdispd{,q} args cmd suf ret=1 local -a args cmd_args -local glob host dir dirprefix +local glob host dir esc dirprefix if zstyle -T ":completion:${curcontext}:files" remote-access; then # Parse options to _remote_files. Stops at the first "--". - zparseopts -D -E -a args / g:=glob h:=host W:=dir + zparseopts -D -E -a args / g:=glob h:=host W:=dir Q:=esc (( $#host)) && shift host || host="${IPREFIX%:}" args=( ${argv[1,(i)--]} ) @@ -85,6 +87,14 @@ if zstyle -T ":completion:${curcontext}:files" remote-access; then remdispf=( ${(M)remdispf:#${~glob[2]}} ) fi + if (( $#esc )); then + remdispfq=(${${remdispf%[*=|]}//(#b)(${~esc[2]})/\\$match[1]}) + remdispdq=(${${remdispd%/}//(#b)(${~esc[2]})/\\$match[1]}) + else + remdispfq=(${(q)remdispf%[*=|]}) + remdispdq=(${(q)remdispd%/}) + fi + local -a autoremove [[ -o autoremoveslash ]] && autoremove=(-r "/ \t\n\-") @@ -92,9 +102,9 @@ if zstyle -T ":completion:${curcontext}:files" remote-access; then while _tags; do while _next_label remote-files expl ${suf:-remote directory}; do [[ -n $suf ]] && - compadd "$args[@]" "$expl[@]" -d remdispf -- ${(q)remdispf%[*=|]} && ret=0 + compadd "$args[@]" "$expl[@]" -d remdispf -- $remdispfq && ret=0 compadd ${suf:+-S/} $autoremove "$args[@]" "$expl[@]" -d remdispd \ - -- ${(q)remdispd%/} && ret=0 + -- $remdispdq && ret=0 done (( ret )) || return 0 done -- cgit v1.2.3