sftp client uses glob() to glob the absolute path + relative path. In the scenario where the current working directory is something like "/tmp/ [testdir]", and you try to retrieve a file "testfile.txt" from that directory doing a get "testfile.txt" or mget "testfile.txt" then sftp client prepends the cwd and the arguments to get and then passes them to a globbing routine. Making it difficult to retrieve files from a directory enclosed in square brackets. sftp should probably not glob at all when using get/put, and only glob the arguments to mget/mput <not the current working directory>.
Created attachment 1284 [details] Report error on read/write failures I'm not sure how much logspam this patch will generate, so I'm going to run with it for a little while.
The content of attachment 1284 [details] has been deleted by Damien Miller <djm@mindrot.org> who provided the following reason: wrong bug The token used to delete this attachment was generated at 2007-05-17 18:42:08.
Created attachment 1291 [details] Permit escaping of glob characters This patch allows escaping of glob characters, so you should be able to do: put "file with \[square braces]" put "file with asterisk\*" and so forth.
Created attachment 1295 [details] Diff with support for unquoted, escaped whitespace This diff merges the previous diff with one from Ben Lindstrom to add support for escaping of whitespace in unquoted filenames. So this will support all of: get "filename with \[glob metacharacters]" get filename\ with\ spaces get filename\ with\ spaces\ and\ \[glob metacharacters]
Created attachment 1357 [details] Rewrite sftp command parsing and glob handling I think this patch is correct: it rewrites sftp's command parsing code to split the string into an argv using sh(1)-like rules, and should handle glob sequences much more naturally. Things like 'rm \*' and 'rm "*"' should work now (i.e. they are not equivalent to 'rm *'), as should more complicated sequences like 'put "[some files] - blah"*' It does need some regress tests though.
Created attachment 1358 [details] Tweaked diff with regress tests The previous diff had a small bug related to glob's handling of backslash characters. This version also adds some regression tests.
Put this on the radar for 4.8
patch is applied - will be in openssh-4.8 This will need a release note, as scripts that depended on the previous broken behaviour may need to change.
Fix shipped in 4.9/4.9p1 release.