-
Notifications
You must be signed in to change notification settings - Fork 391
fix(rsync,ssh,sshfs): do not generate regular files *'\' as dirs #1397
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
base: main
Are you sure you want to change the base?
Conversation
7d3fe02
to
928fe7a
Compare
Maybe add a test with remote files for scp? |
928fe7a
to
6c8fb9c
Compare
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 /[^/]/.
6c8fb9c
to
0695e8a
Compare
else | ||
# escape problematic characters; remove executables, aliases, pipes | ||
# and sockets; add space at end of file names | ||
# 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' \ | ||
-e 's/[^\/]$/& /g') | ||
-e 's/[^/]$/& /g') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to add a test for this if
-branch, but it seems difficult to test it within the current test framework. This branch tries to append a space when it is not a directory, but bash-completion
's test framework removes the trailing whitespace when it extracts the generated completions. As a result, we cannot detect whether a suffix space is added by the completion function or not.
)" | ||
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-}/" | ||
-e 's/[*@|=]$//g' -e 's/[^/]$/& /g' -e "s/^/${1-}/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A test for the local-path generation without -d
has the same issue. We cannot check the trailing space within the current test framework.
Yeah, this is actually the same error as the |
This was a part of #1371 but was separated. Waiting for #1396.
Details are described in the commit message.