From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Albinus Newsgroups: gmane.emacs.devel Subject: Re: File names with spaces and tramp/ftp Date: Tue, 12 Feb 2008 14:00:48 +0100 Message-ID: References: <47AA3211.3010804@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1202821224 25469 80.91.229.12 (12 Feb 2008 13:00:24 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 12 Feb 2008 13:00:24 +0000 (UTC) Cc: Eli Zaretskii , lennart.borgman@gmail.com, emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Feb 12 14:00:47 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JOukb-0005wN-Mi for ged-emacs-devel@m.gmane.org; Tue, 12 Feb 2008 14:00:41 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JOuk7-0003Cd-VO for ged-emacs-devel@m.gmane.org; Tue, 12 Feb 2008 08:00:12 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JOuk0-0003AE-Tp for emacs-devel@gnu.org; Tue, 12 Feb 2008 08:00:04 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JOujy-00038e-V9 for emacs-devel@gnu.org; Tue, 12 Feb 2008 08:00:04 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JOujy-00038b-LX for emacs-devel@gnu.org; Tue, 12 Feb 2008 08:00:02 -0500 Original-Received: from mailrelay1.alcatel.de ([194.113.59.95]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1JOujt-0004Vd-2M; Tue, 12 Feb 2008 07:59:57 -0500 Original-Received: from slbhab.alcatel.de (slbhab.bln.sel.alcatel.de [149.204.63.218]) by mailrelay1.alcatel.de (8.13.8/8.13.8/ICT) with ESMTP id m1CCxqqh011849; Tue, 12 Feb 2008 13:59:52 +0100 In-Reply-To: (Stefan Monnier's message of "Mon, 11 Feb 2008 22:16:34 -0500") User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (hpux) X-Scanned-By: MIMEDefang 2.57 on 149.204.45.72 X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:88860 Archived-At: --=-=-= Stefan Monnier writes: >>> I could change ange-ftp to this encoding style of file names; but I am >>> anxious: it could break ange-ftp on other systems, where double quotes >>> might not be supported. > >> Does it help to use shell-quote-argument? > > I doubt it: the FTP command is not passed through a shell. > In some cases it may work, of course. But it is a good approximation. Under GNU/Linux, we have (shell-quote-argument "file name with spaces 'and \"quotes") => "file\\ name\\ with\\ spaces\\ \\'and\\ \\\"quotes" W32 systems do (shell-quote-argument "file name with spaces 'and \"quotes") => "\"file name with spaces 'and \\\"quotes\"" Both quotations work with stock FTP clients except the quotation of "\"" on W32 systems: it shall be "\"\" instead of "\\\"". But this could be adapted, and "\"" isn't so usual on W32 file names. Btw, I could not create the file "~/file name with spaces 'and \"quotes" on W32 in Emacs; this worked only with Emacs under GNU/Linux. Lennart (et al), could you, please, test whether the appended patch works for you for file names with spaces? And that there isn't any other regression? The patch is towards ange-ftp.el in the trunk. > Stefan Best regards, Michael. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment *** /usr/local/src/emacs/lisp/net/ange-ftp.el.~1~ Wed Feb 6 20:49:56 2008 --- /usr/local/src/emacs/lisp/net/ange-ftp.el Tue Feb 12 13:46:33 2008 *************** *** 1523,1541 **** (defun ange-ftp-quote-string (string) "Quote any characters in STRING that may confuse the ftp process." ! (apply 'concat ! (mapcar (lambda (char) ! ;; This is said to be wrong; ftp is said to ! ;; need quoting only for ", and that by doubling it. ! ;; But experiment says this kind of quoting is correct ! ;; when talking to ftp on GNU/Linux systems. ! (if (or (<= char ? ) ! (> char ?\~) ! (= char ?\") ! (= char ?\\)) ! (vector ?\\ char) ! (vector char))) ! string))) (defun ange-ftp-barf-if-not-directory (directory) (or (file-directory-p directory) --- 1523,1529 ---- (defun ange-ftp-quote-string (string) "Quote any characters in STRING that may confuse the ftp process." ! (when (stringp string) (shell-quote-argument string))) (defun ange-ftp-barf-if-not-directory (directory) (or (file-directory-p directory) *************** *** 3766,3772 **** (ange-ftp-send-cmd t-host t-user ! (list 'put (or temp2 filename) t-name) (or msg (if (and temp2 f-parsed) (format "Putting %s" newname) --- 3754,3760 ---- (ange-ftp-send-cmd t-host t-user ! (list 'put (or temp2 (ange-ftp-quote-string filename)) t-name) (or msg (if (and temp2 f-parsed) (format "Putting %s" newname) --=-=-=--