Skip to content

[Waiting for #1397] fix(rsync,scp): remove file-type marks from "ls -F" properly #1398

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
8 changes: 5 additions & 3 deletions completions/ssh
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,8 @@ _comp_xfunc_scp_compgen_remote_files()
# shellcheck disable=SC2090
_files=$(ssh -o 'Batchmode yes' "$_userhost" \
command ls -aF1dL "$_path*" 2>/dev/null |
command sed -e 's/'"$_comp_cmd_scp__path_esc"'/'"$_escape_replacement"'/g' -e 's/[*@|=]$//g' \
command sed -e 's/[*@|=]$//g' \
-e 's/'"$_comp_cmd_scp__path_esc"'/'"$_escape_replacement"'/g' \
-e 's/[^/]$/& /g')
fi
_comp_compgen -R split -l -- "$_files"
Expand Down Expand Up @@ -555,8 +556,9 @@ _comp_xfunc_scp_compgen_local_files()
else
_comp_compgen -RU files split -l -- "$(
command ls -aF1dL "${files[@]}" 2>/dev/null |
command sed -e "s/$_comp_cmd_scp__path_esc/\\\\&/g" \
-e 's/[*@|=]$//g' -e 's/[^/]$/& /g' -e "s/^/${1-}/"
command sed -e 's/[*@|=]$//g' \
-e "s/$_comp_cmd_scp__path_esc/\\\\&/g" \
-e 's/[^/]$/& /g' -e "s/^/${1-}/"
)"
fi
}
Expand Down
26 changes: 25 additions & 1 deletion test/t/test_scp.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@

import pytest

from conftest import assert_bash_exec, assert_complete, bash_env_saved
from conftest import (
assert_bash_exec,
assert_complete,
bash_env_saved,
prepare_fixture_dir,
)

LIVE_HOST = os.environ.get(
"BASH_COMPLETION_TEST_LIVE_SSH_HOST", default="bash_completion"
Expand Down Expand Up @@ -152,3 +157,22 @@ def test_xfunc_remote_files(self, bash):
"shared/default/foo ",
"shared/default/foo.d/",
]

@pytest.fixture
def tmpdir_mkfifo(self, request, bash):
tmpdir, _, _ = prepare_fixture_dir(request, files=[], dirs=[])

try:
assert_bash_exec(bash, "mkfifo '%s/local_path_1-pipe'" % tmpdir)
except Exception:
pytest.skip(
"The present system does not allow creating a named pipe."
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there's a valid setup that would allow creating these, but just doesn't have mkfifo installed. The end result would be the same, but the skip message would be misleading. Maybe include the stringified exception in it and generalize a bit, something like f"Could not create a named pipe: {ex}"?

Pre-approved with this addressed some way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if there's a valid setup that would allow creating these, but just doesn't have mkfifo installed.

I anticipated the opposite situation, where mkfifo is installed, yet creating a named pipe is not allowed. For example, MSYS 1.0 doesn't support creating a named pipe:

$ mkfifo a.pipe
mkfifo: cannot create fifo `a.pipe': Function not implemented

Although I haven't tried, I also wonder if we can create a named pipe inside a USB memory stick (whose filesystem is usually FAT32).

)

return tmpdir

def test_local_path_mark_1(self, bash, tmpdir_mkfifo):
completion = assert_complete(
bash, "scp local_path_1-", cwd=tmpdir_mkfifo
)
assert completion == "pipe"