Skip to content

Commit 69c6a51

Browse files
authored
Merge pull request #1371 from akinomyoga/scp-refactor-1
fix(scp,rsync): fix misc bugs and refactor
2 parents 0396d24 + b9680a7 commit 69c6a51

File tree

5 files changed

+14
-18
lines changed

5 files changed

+14
-18
lines changed

bash_completion

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2860,7 +2860,7 @@ _comp_command_offset()
28602860
_comp_compgen_commands
28612861
else
28622862
_comp_dequote "${COMP_WORDS[0]}" || REPLY=${COMP_WORDS[0]}
2863-
local cmd=$REPLY compcmd=$REPLY
2863+
local cmd=${REPLY-} compcmd=${REPLY-}
28642864
local cspec=$(complete -p -- "$cmd" 2>/dev/null)
28652865

28662866
# If we have no completion for $cmd yet, see if we have for basename

completions/ssh

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ _comp_cmd_ssh()
302302

303303
_comp_cmd_ssh__compgen_suboption_check "$1" && return
304304

305-
local ipvx
305+
local ipvx=
306306

307307
# Keep cases sorted the same they're in ssh's usage message
308308
# (but do group ones with same arg completion)
@@ -459,7 +459,6 @@ _comp_cmd_sftp()
459459
shopt -u hostcomplete && complete -F _comp_cmd_sftp sftp
460460

461461
# things we want to backslash escape in scp paths
462-
# shellcheck disable=SC2089
463462
_comp_cmd_scp__path_esc='[][(){}<>"'"'"',:;^&!$=?`\\|[:space:]]'
464463

465464
# Complete remote files with ssh. Returns paths escaped with three backslashes
@@ -493,7 +492,6 @@ _comp_xfunc_scp_compgen_remote_files()
493492
local _path=${cur#*:}
494493

495494
# unescape (3 backslashes to 1 for chars we escaped)
496-
# shellcheck disable=SC2090
497495
_path=$(command sed -e 's/\\\\\\\('"$_comp_cmd_scp__path_esc"'\)/\\\1/g' <<<"$_path")
498496

499497
# default to home dir of specified user on remote host
@@ -509,14 +507,12 @@ _comp_xfunc_scp_compgen_remote_files()
509507
local _files
510508
if [[ $_dirs_only ]]; then
511509
# escape problematic characters; remove non-dirs
512-
# shellcheck disable=SC2090
513510
_files=$(ssh -o 'Batchmode yes' "$_userhost" \
514511
command ls -aF1dL "$_path*" 2>/dev/null |
515512
command sed -e 's/'"$_comp_cmd_scp__path_esc"'/'"$_escape_replacement"'/g' -e '/[^/]$/d')
516513
else
517514
# escape problematic characters; remove executables, aliases, pipes
518515
# and sockets; add space at end of file names
519-
# shellcheck disable=SC2090
520516
_files=$(ssh -o 'Batchmode yes' "$_userhost" \
521517
command ls -aF1dL "$_path*" 2>/dev/null |
522518
command sed -e 's/[*@|=]$//g' \
@@ -539,26 +535,26 @@ _scp_remote_files()
539535
# @since 2.12
540536
_comp_xfunc_scp_compgen_local_files()
541537
{
542-
local _dirsonly=""
538+
local _dirs_only=""
543539
if [[ ${1-} == -d ]]; then
544-
_dirsonly=set
540+
_dirs_only=set
545541
shift
546542
fi
547543

548544
local files
549545
_comp_expand_glob files '"$cur"*' || return 0
550-
if [[ $_dirsonly ]]; then
551-
_comp_compgen -RU files split -l -- "$(
546+
if [[ $_dirs_only ]]; then
547+
_comp_compgen -RU files split -l ${1:+-P "$1"} -- "$(
552548
command ls -aF1dL "${files[@]}" 2>/dev/null |
553549
command sed -e "s/$_comp_cmd_scp__path_esc/\\\\&/g" \
554-
-e '/[^/]$/d' -e "s/^/${1-}/"
550+
-e '/[^/]$/d'
555551
)"
556552
else
557-
_comp_compgen -RU files split -l -- "$(
553+
_comp_compgen -RU files split -l ${1:+-P "$1"} -- "$(
558554
command ls -aF1dL "${files[@]}" 2>/dev/null |
559555
command sed -e 's/[*@|=]$//g' \
560556
-e "s/$_comp_cmd_scp__path_esc/\\\\&/g" \
561-
-e 's/[^/]$/& /g' -e "s/^/${1-}/"
557+
-e 's/[^/]$/& /g'
562558
)"
563559
fi
564560
}
@@ -588,7 +584,7 @@ _comp_cmd_scp()
588584
return
589585
}
590586

591-
local ipvx
587+
local ipvx=
592588

593589
case $prev in
594590
-*c)
@@ -640,7 +636,7 @@ _comp_cmd_scp()
640636
;;
641637
esac
642638

643-
local prefix
639+
local prefix=
644640

645641
if [[ $cur == -F* ]]; then
646642
cur=${cur#-F}

test/t/test_cancel.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def added_job(self, request, bash):
1616
)
1717
except AssertionError:
1818
pytest.skip("Could not add test print job")
19-
return
19+
2020
if len(got) > 3:
2121
request.addfinalizer(
2222
lambda: assert_bash_exec(bash, "cancel %s" % got[3])

test/t/test_ls.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def test_3(self, bash):
3333
part_full = find_unique_completion_pair(res)
3434
if not part_full:
3535
pytest.skip("No suitable test user found")
36-
return
36+
3737
part, full = part_full
3838
completion = assert_complete(bash, "ls ~%s" % part)
3939
assert completion == full[len(part) :]

test/t/test_man.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def colonpath(self, request, bash):
2323
pass
2424
else:
2525
pytest.skip("Cygwin doesn't like paths with colons")
26-
return
26+
2727
tmpdir, _, _ = prepare_fixture_dir(
2828
request,
2929
files=["man/man3/Bash::Completion.3pm.gz"],

0 commit comments

Comments
 (0)