Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions completions-core/rsync.bash
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ _comp_cmd_rsync()
# meaning before v3.2.0) contain the following unusual line in
# --help:
# "(-h) --help show this help (-h is --help only if used alone)"
if _comp_compgen -Rv tmp help - <<<"$("$1" --help 2>&1 | command sed -e 's/^([^)]*)//')"; then
if _comp_compgen -Rv tmp help - <<<"$(command rsync --help 2>&1 | command sed -e 's/^([^)]*)//')"; then

_comp_compgen -- -W '"${tmp[@]}"
--daemon --old-d{,irs}
Expand All @@ -106,7 +106,7 @@ _comp_cmd_rsync()
fi
done
if [[ $shell == ssh ]]; then
local rsync_version=$("$1" --version 2>/dev/null |
local rsync_version=$(command rsync --version 2>/dev/null |
command sed -n '1s/.*rsync *version \([0-9.]*\).*/\1/p')
_comp_cmd_rsync__vercomp "$rsync_version" "3.2.4"
if (($? == 2)); then
Expand Down
28 changes: 27 additions & 1 deletion test/t/test_rsync.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from conftest import assert_bash_exec, assert_complete
from conftest import assert_bash_exec, assert_complete, is_bash_type


@pytest.mark.bashcomp(ignore_env=r"^[+-]_comp_cmd_scp__path_esc=")
Expand Down Expand Up @@ -75,6 +75,32 @@ def test_remote_path_with_spaces(self, bash):
or completion == r"\\\ in\\\ filename.txt"
)

def test_alias_options(self, bash):
"""Options for a manually registered alias match the real command."""
if not is_bash_type(bash, "rsync"):
pytest.skip("Command not found")
assert_bash_exec(
bash,
"alias _comp_test_rsync_alias=rsync",
)
assert_bash_exec(
bash,
"complete -o nospace -F _comp_cmd_rsync _comp_test_rsync_alias",
)
try:
expected = assert_complete(bash, "rsync --")
completion = assert_complete(
bash,
"_comp_test_rsync_alias --",
)
assert completion == expected
finally:
assert_bash_exec(
bash,
"unalias _comp_test_rsync_alias; "
"complete -r _comp_test_rsync_alias 2>/dev/null || true",
)

@pytest.mark.complete(r"rsync -na spaced\ ", cwd="scp")
def test_local_path_with_spaces(self, completion):
"""This function tests xfunc _comp_xfunc_scp_compgen_local_files, which
Expand Down
Loading