Skip to content

Commit 6c8fb9c

Browse files
committed
fix(rsync,ssh,sshfs): do not generate regular files *'\' as dirs
In sed, /[^\/]/ does not mean "a character that is not a slash". It means "a character that is not a backslash or a slash". In the bracket expressions [...], slashes do not need to be escaped by a backslash, and also, a backslash is treated literally. We should instead use /[^/]/.
1 parent 6bd5e26 commit 6c8fb9c

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

completions/ssh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -512,15 +512,15 @@ _comp_xfunc_scp_compgen_remote_files()
512512
# shellcheck disable=SC2090
513513
_files=$(ssh -o 'Batchmode yes' "$_userhost" \
514514
command ls -aF1dL "$_path*" 2>/dev/null |
515-
command sed -e 's/'"$_comp_cmd_scp__path_esc"'/'"$_escape_replacement"'/g' -e '/[^\/]$/d')
515+
command sed -e 's/'"$_comp_cmd_scp__path_esc"'/'"$_escape_replacement"'/g' -e '/[^/]$/d')
516516
else
517517
# escape problematic characters; remove executables, aliases, pipes
518518
# and sockets; add space at end of file names
519519
# shellcheck disable=SC2090
520520
_files=$(ssh -o 'Batchmode yes' "$_userhost" \
521521
command ls -aF1dL "$_path*" 2>/dev/null |
522522
command sed -e 's/'"$_comp_cmd_scp__path_esc"'/'"$_escape_replacement"'/g' -e 's/[*@|=]$//g' \
523-
-e 's/[^\/]$/& /g')
523+
-e 's/[^/]$/& /g')
524524
fi
525525
_comp_compgen -R split -l -- "$_files"
526526
}
@@ -550,13 +550,13 @@ _comp_xfunc_scp_compgen_local_files()
550550
_comp_compgen -RU files split -l -- "$(
551551
command ls -aF1dL "${files[@]}" 2>/dev/null |
552552
command sed -e "s/$_comp_cmd_scp__path_esc/\\\\&/g" \
553-
-e '/[^\/]$/d' -e "s/^/${1-}/"
553+
-e '/[^/]$/d' -e "s/^/${1-}/"
554554
)"
555555
else
556556
_comp_compgen -RU files split -l -- "$(
557557
command ls -aF1dL "${files[@]}" 2>/dev/null |
558558
command sed -e "s/$_comp_cmd_scp__path_esc/\\\\&/g" \
559-
-e 's/[*@|=]$//g' -e 's/[^\/]$/& /g' -e "s/^/${1-}/"
559+
-e 's/[*@|=]$//g' -e 's/[^/]$/& /g' -e "s/^/${1-}/"
560560
)"
561561
fi
562562
}

test/fixtures/sshfs/local_path-dir/dummy.txt

Whitespace-only changes.

test/fixtures/sshfs/local_path-file\

Whitespace-only changes.

test/t/test_sshfs.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ class TestSshfs:
66
@pytest.mark.complete("sshfs ./")
77
def test_1(self, completion):
88
assert completion
9+
10+
@pytest.mark.complete("sshfs local_path", cwd="sshfs")
11+
def test_local_path_suffix_1(self, completion):
12+
assert completion == "-dir/"

0 commit comments

Comments
 (0)