Skip to content

Commit 078ab1e

Browse files
committed
fix(rsync): Try getting rsync arguments BSD style
There is a BSD licensed version of rsync at https://github.com/kristapsdz/openrsync, and its what comes with macOS
1 parent ab928cd commit 078ab1e

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

completions/rsync

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,15 @@ _comp_cmd_rsync()
8585
# meaning before v3.2.0) contain the following unusual line in
8686
# --help:
8787
# "(-h) --help show this help (-h is --help only if used alone)"
88-
_comp_compgen -Rv tmp help - <<<"$("$1" --help 2>&1 | command sed -e 's/^([^)]*)//')"
88+
if _comp_compgen -Rv tmp help - <<<"$("$1" --help 2>&1 | command sed -e 's/^([^)]*)//')"; then
8989

90-
_comp_compgen -- -W '"${tmp[@]}"
91-
--daemon --old-d{,irs}
92-
--no-{blocking-io,detach,whole-file,inc-recursive,i-r}' -X '--no-OPTION'
90+
_comp_compgen -- -W '"${tmp[@]}"
91+
--daemon --old-d{,irs}
92+
--no-{blocking-io,detach,whole-file,inc-recursive,i-r}' -X '--no-OPTION'
93+
# We didn't find any options using _comp_compgen_help, try _usage for BSD style usage
94+
else
95+
_comp_compgen_usage
96+
fi
9397
[[ ${COMPREPLY-} == *= ]] || compopt +o nospace
9498
;;
9599
*:*)

test/t/test_rsync.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ def test_2(self, completion):
1717
def test_3(self, completion):
1818
assert completion == "rsh ssh".split()
1919

20-
@pytest.mark.complete("rsync --", require_cmd=True)
20+
@pytest.mark.complete("rsync --", require_longopt=True)
2121
def test_4(self, completion):
22-
assert "--help" in completion
22+
assert "--compress" in completion
23+
assert "--timeout=" in completion
2324

2425
@pytest.mark.parametrize(
2526
"ver1,ver2,result",

0 commit comments

Comments
 (0)