completions/scp: silence error on unexpected version

There seem to be versions of ssh (possibly not from OpenSSH) that don't
print the version number in -V, so make sure not to pass an empty string as
numeric arg to test.

Fixes #10445
This commit is contained in:
Johannes Altmanninger 2024-04-17 09:48:45 +02:00
parent 85b3dbbec0
commit 2e42d80dc9

View File

@ -44,8 +44,7 @@ complete -c scp -d "Local Path" -n "not string match @ -- (commandline -ct)"
# Remote path
# Get the list of remote files from the scp target.
string match -rq 'OpenSSH(_for_Windows)?_(?<major>\d+)\.*' -- (ssh -V 2>&1)
if test "$major" -ge 9
if string match -rq 'OpenSSH(_for_Windows)?_(?<major>\d+)\.*' -- (ssh -V 2>&1) && test "$major" -ge 9
complete -c scp -d "Remote Path" -f -n "commandline -ct | string match -e ':'" -a "
(__scp_remote_target):( \
command ssh (__scp2ssh_port_number) -o 'BatchMode yes' (__scp_remote_target) command\ ls\ -dp\ (__scp_remote_path_prefix)\* 2>/dev/null