From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: samer Newsgroups: gmane.emacs.bugs Subject: bug#8531: 24.0.50; shell-quote-argument shouldn't escape special characters Date: Mon, 08 Dec 2014 08:48:15 -0800 Message-ID: References: <8762q8xe3i.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1418057427 3900 80.91.229.3 (8 Dec 2014 16:50:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 8 Dec 2014 16:50:27 +0000 (UTC) To: 8531@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Dec 08 17:50:20 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Xy1Vr-0007vv-TC for geb-bug-gnu-emacs@m.gmane.org; Mon, 08 Dec 2014 17:50:20 +0100 Original-Received: from localhost ([::1]:34922 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xy1Vr-0000kc-Hk for geb-bug-gnu-emacs@m.gmane.org; Mon, 08 Dec 2014 11:50:19 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51912) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xy1Vj-0000iE-51 for bug-gnu-emacs@gnu.org; Mon, 08 Dec 2014 11:50:16 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xy1Va-0000ip-SY for bug-gnu-emacs@gnu.org; Mon, 08 Dec 2014 11:50:11 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:60642) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xy1Va-0000iV-PO for bug-gnu-emacs@gnu.org; Mon, 08 Dec 2014 11:50:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Xy1Va-0002Aj-9I for bug-gnu-emacs@gnu.org; Mon, 08 Dec 2014 11:50:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <8762q8xe3i.fsf@gmail.com> Resent-From: samer Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 08 Dec 2014 16:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 8531 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.14180573528271 (code B ref -1); Mon, 08 Dec 2014 16:50:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 8 Dec 2014 16:49:12 +0000 Original-Received: from localhost ([127.0.0.1]:57855 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xy1Ul-00029K-8n for submit@debbugs.gnu.org; Mon, 08 Dec 2014 11:49:11 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:49943) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Xy1Ui-00029B-9S for submit@debbugs.gnu.org; Mon, 08 Dec 2014 11:49:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xy1Uc-0000SL-FS for submit@debbugs.gnu.org; Mon, 08 Dec 2014 11:49:08 -0500 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:46990) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xy1Uc-0000SH-CZ for submit@debbugs.gnu.org; Mon, 08 Dec 2014 11:49:02 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51645) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xy1UX-0000b2-G1 for bug-gnu-emacs@gnu.org; Mon, 08 Dec 2014 11:49:02 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xy1US-0000RZ-L2 for bug-gnu-emacs@gnu.org; Mon, 08 Dec 2014 11:48:57 -0500 Original-Received: from samertm.com ([162.243.37.26]:51935 helo=mail.samertm.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xy1US-0000Kw-Gg for bug-gnu-emacs@gnu.org; Mon, 08 Dec 2014 11:48:52 -0500 Original-Received: from samertm.com (localhost [127.0.0.1]) by mail.samertm.com (Postfix) with ESMTP id E1F488076F for ; Mon, 8 Dec 2014 16:48:15 +0000 (UTC) X-Sender: samer@samertm.com User-Agent: Roundcube Webmail/0.9.5 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:97004 Archived-At: Hi, I found this bug on debbugs thanks to Lars' getting started guide. This change simplifies the code by making the behavior that used occur for newlines following a backslash, returning the character literal after the backslash, the behavior that occurs for _all_ non-special characters. This is my first contribution to emacs, so don't hesitate to correct anything nonstandard in the patch I've included. I'm interested in doing more work on eshell, too. What eshell bugs would benefit from a fresh pair of eyes? Also, I sent this email to 8531@debbugs.gnu.org five hours and I didn't see my email on debbugs. Apologies for the duplication if that email actually went through. Best, Samer Patch for esh-arg.el: *** /home/samer/build/emacs120714/share/emacs/25.0.50/lisp/eshell/esh-arg.el.gz.old --- /home/samer/build/emacs120714/share/emacs/25.0.50/lisp/eshell/esh-arg.el.gz *************** *** 89,95 **** (goto-char (match-end 0)) (eshell-finish-arg))))) ! ;; backslash before a special character means escape it 'eshell-parse-backslash ;; text beginning with ' is a literally quoted --- 89,96 ---- (goto-char (match-end 0)) (eshell-finish-arg))))) ! ;; backslash before a character escapes it if the character is ! ;; special, and returns the character literal if it is non-special 'eshell-parse-backslash ;; text beginning with ' is a literally quoted *************** *** 282,294 **** "A stub function that generates an error if a floating operator is found." (error "Unhandled operator in input text")) - (defsubst eshell-looking-at-backslash-return (pos) - "Test whether a backslash-return sequence occurs at POS." - (and (eq (char-after pos) ?\\) - (or (= (1+ pos) (point-max)) - (and (eq (char-after (1+ pos)) ?\n) - (= (+ pos 2) (point-max)))))) - (defun eshell-quote-backslash (string &optional index) "Intelligently backslash the character occurring in STRING at INDEX. If the character is itself a backslash, it needs no escaping." --- 283,288 ---- *************** *** 305,313 **** (string ?\\ char))))) (defun eshell-parse-backslash () ! "Parse a single backslash (\) character, which might mean escape. ! It only means escape if the character immediately following is a ! special character that is not itself a backslash." (when (eq (char-after) ?\\) (if (eshell-looking-at-backslash-return (point)) (throw 'eshell-incomplete ?\\) --- 299,309 ---- (string ?\\ char))))) (defun eshell-parse-backslash () ! "Parse a single backslash (\) character to escape the character after. ! If the character immediately following the backslash is a special ! character, it returns the escaped version of that character. ! Else, the character has no meaning and is returned as the literal ! character. This conforms with the behavior of bash." (when (eq (char-after) ?\\) (if (eshell-looking-at-backslash-return (point)) (throw 'eshell-incomplete ?\\) *************** *** 321,338 **** (forward-char 2) (list 'eshell-escape-arg (char-to-string (char-before)))) - ;; allow \\ to mean a literal "\" character followed by a - ;; normal return, rather than a backslash followed by a line - ;; continuation (i.e., "\\ + \n" rather than "\ + \\n"). This - ;; is necessary because backslashes in Eshell are not special - ;; unless they either precede something special, or precede a - ;; backslash that precedes something special. (Mainly this is - ;; done to make using backslash on Windows systems more - ;; natural-feeling). - (if (eshell-looking-at-backslash-return (1+ (point))) - (forward-char)) (forward-char) ! "\\")))) (defun eshell-parse-literal-quote () "Parse a literally quoted string. Nothing has special meaning!" --- 317,325 ---- (forward-char 2) (list 'eshell-escape-arg (char-to-string (char-before)))) (forward-char) ! (forward-char) ! (char-before))))) (defun eshell-parse-literal-quote () "Parse a literally quoted string. Nothing has special meaning!" Diff finished. Mon Dec 8 01:23:11 2014 *** /home/samer/build/emacs120714/share/emacs/25.0.50/lisp/eshell/esh-arg.el.gz.old --- /home/samer/build/emacs120714/share/emacs/25.0.50/lisp/eshell/esh-arg.el.gz *************** *** 89,95 **** (goto-char (match-end 0)) (eshell-finish-arg))))) ! ;; backslash before a special character means escape it 'eshell-parse-backslash ;; text beginning with ' is a literally quoted --- 89,96 ---- (goto-char (match-end 0)) (eshell-finish-arg))))) ! ;; backslash before a character escapes it if the character is ! ;; special, and returns the character literal if it is non-special 'eshell-parse-backslash ;; text beginning with ' is a literally quoted *************** *** 282,294 **** "A stub function that generates an error if a floating operator is found." (error "Unhandled operator in input text")) - (defsubst eshell-looking-at-backslash-return (pos) - "Test whether a backslash-return sequence occurs at POS." - (and (eq (char-after pos) ?\\) - (or (= (1+ pos) (point-max)) - (and (eq (char-after (1+ pos)) ?\n) - (= (+ pos 2) (point-max)))))) - (defun eshell-quote-backslash (string &optional index) "Intelligently backslash the character occurring in STRING at INDEX. If the character is itself a backslash, it needs no escaping." --- 283,288 ---- *************** *** 305,313 **** (string ?\\ char))))) (defun eshell-parse-backslash () ! "Parse a single backslash (\) character, which might mean escape. ! It only means escape if the character immediately following is a ! special character that is not itself a backslash." (when (eq (char-after) ?\\) (if (eshell-looking-at-backslash-return (point)) (throw 'eshell-incomplete ?\\) --- 299,309 ---- (string ?\\ char))))) (defun eshell-parse-backslash () ! "Parse a single backslash (\) character to escape the character after. ! If the character immediately following the backslash is a special ! character, it returns the escaped version of that character. ! Else, the character has no meaning and is returned as the literal ! character. This conforms with the behavior of bash." (when (eq (char-after) ?\\) (if (eshell-looking-at-backslash-return (point)) (throw 'eshell-incomplete ?\\) *************** *** 321,338 **** (forward-char 2) (list 'eshell-escape-arg (char-to-string (char-before)))) - ;; allow \\ to mean a literal "\" character followed by a - ;; normal return, rather than a backslash followed by a line - ;; continuation (i.e., "\\ + \n" rather than "\ + \\n"). This - ;; is necessary because backslashes in Eshell are not special - ;; unless they either precede something special, or precede a - ;; backslash that precedes something special. (Mainly this is - ;; done to make using backslash on Windows systems more - ;; natural-feeling). - (if (eshell-looking-at-backslash-return (1+ (point))) - (forward-char)) (forward-char) ! "\\")))) (defun eshell-parse-literal-quote () "Parse a literally quoted string. Nothing has special meaning!" --- 317,325 ---- (forward-char 2) (list 'eshell-escape-arg (char-to-string (char-before)))) (forward-char) ! (forward-char) ! (char-before))))) (defun eshell-parse-literal-quote () "Parse a literally quoted string. Nothing has special meaning!"