Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: OpenSSH scp completion reminder
On 4/14/22, Axel Beckert <abe@xxxxxxxxxxxxxxx> wrote:
> Hi,
>
> On Thu, Apr 14, 2022 at 10:04:42AM -0700, Bart Schaefer wrote:
>> On Thu, Apr 14, 2022 at 9:43 AM Axel Beckert <abe@xxxxxxxxxxxxxxx> wrote:
>> > On Thu, Apr 14, 2022 at 11:20:34AM -0400, Phil Pennock wrote:
>> > > This change impacts quoting of things like whitespace.
>> > > Which I have assumed will impact zsh completion.
>> >
>> > I thought so as well, but I so far couldn't find anything which didn't
>> > work with zsh remote file completion with OpenSSH 9.0 on the client
>> > side.
>>
>> Completion itself doesn't use scp to do the remote file name
>> generation, it uses plain ssh. Of course once the file names are
>> returned, getting the quoting right for the actual scp invocation is
>> down to what appears on the command line, so the only way completion
>> could be implicated in messing this up is if it somehow automatically
>> inserted the wrong quoting.
>
> Yep, and that's the point: In theory, the amount of quoting (e.g.
> three backslashes vs one backslash) is expected to be different with
> the different scp backends. But for some reason the variant with three
> backslashes still worked for me with OpenSSH 9.0 on the client side
> which defaults to use the SFTP backend which does no shell globbing or
> escaping on the server side.
>
> To copy a file named "tmp/foo bar" from remotehost to my local
> directory "tmp/", I did:
>
> % scp -p remotehost:tmp/foo<Tab><Tab> tmp/<Enter>
>
> It expanded to:
>
> % scp -p remotehost:tmp/foo\\\ bar tmp/
>
> Accoding to the docs, this does no more work with OpenSSH 9.0's
> default settings, but it did. Running "scp" with "-vvvv" confirms that
> the new default (SFTP backend) is used:
>
> scp -pvvvv remotehost:tmp/foo\\\ bar tmp/ |& fgrep tmp/foo
> scp: debug3: sink_sftp: copying remote tmp/foo\\ bar to local tmp/
> scp: debug1: Fetching tmp/foo bar to tmp/foo bar
> scp: debug2: do_download: download remote "tmp/foo bar" to local "tmp/foo
> bar"
> scp: debug2: Sending SSH2_FXP_STAT "tmp/foo bar"
> scp: debug2: Sending SSH2_FXP_OPEN "tmp/foo bar"
> scp: debug3: Sent remote message SSH2_FXP_OPEN I:4 P:tmp/foo bar
> M:0x0001
>
> It seems as if scp has some capability to recognize of there's too
> much shell quoting in a file name and reducres it, since there are
> still two backslashes in the first line with "debug3:" which vanish
> after that line.
>
> And this even seems to go wrong if I want to copy a file created with
> "touch 'foo\ bar'", i.e. with an backslash in there. I would have had
> expected that OpenSSH 9.0 would fetch that file with "scp -p
> remotehost:tmp/foo\\\ bar tmp/" but it actually stripped the file name
> down and I needed five backslashes:
>
> scp -pvvvv remotehost:tmp/foo\\\\\ bar tmp/ |& fgrep tmp/foo
> scp: debug3: sink_sftp: copying remote tmp/foo\\\\ bar to local tmp/
> scp: debug1: Fetching tmp/foo\\ bar to tmp/foo\\ bar
> scp: debug2: do_download: download remote "tmp/foo\\ bar" to local
> "tmp/foo\\ bar"
> scp: debug2: Sending SSH2_FXP_STAT "tmp/foo\\ bar"
> scp: debug2: Sending SSH2_FXP_OPEN "tmp/foo\\ bar"
> scp: debug3: Sent remote message SSH2_FXP_OPEN I:4 P:tmp/foo\\ bar
> M:0x0001
>
> Looks like either a bug in OpenSSH 9.0 or an undocumented
> compatibility feature to me.
It's definitely a bug (I'm using 8.9 though):
% touch '\;\['
% scp -s localhost:\\\;\\\[ .
scp: \\;\\[: No such file or directory
% scp -s localhost:\;\[ .
scp: ;[: No such file or directory
It doesn't seem possible to copy files with backslashes in the name at
all using -s.
--
Mikael Magnusson
Messages sorted by:
Reverse Date,
Date,
Thread,
Author