File tree 1 file changed +15
-1
lines changed 1 file changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -544,7 +544,21 @@ _comp_xfunc_scp_compgen_remote_files()
544
544
local REPLY=$cur
545
545
if [[ ! $_less_escaping ]]; then
546
546
# unescape (3 backslashes to 1 for chars we escaped)
547
- REPLY=$( command sed -e ' s/\\\\\\\(' " $_comp_cmd_scp__path_esc " ' \)/\\\1/g' <<< " $REPLY" )
547
+ #
548
+ # Note: We want to do the following, but POSIX BRE does not support \|:
549
+ #
550
+ # REPLY=$(command sed -e 's/\\\\\\\('"$_comp_cmd_scp__path_esc"'\|$\)/\\\1/g' <<<"$REPLY")
551
+ #
552
+ # Note: We need to store \\\\\\ in a variable to work around "shopt -s
553
+ # compat31".
554
+ local _tail=$REPLY _regex_triple_backslashes=' \\\\\\(' $_comp_cmd_scp__path_esc ' |$)(.*)$'
555
+ REPLY=
556
+ while [[ $_tail && $_tail =~ $_regex_triple_backslashes ]]; do
557
+ # shellcheck disable=SC1003
558
+ REPLY=${_tail:: ${# _tail} -${# BASH_REMATCH} } ' \' ${BASH_REMATCH[1]}
559
+ _tail=${BASH_REMATCH[2]}
560
+ done
561
+ REPLY+=$_tail
548
562
fi
549
563
_comp_dequote_incomplete " $REPLY "
550
564
local cur_val=${REPLY-}
You can’t perform that action at this time.
0 commit comments