all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: samer <samer@samertm.com>
To: 8531@debbugs.gnu.org
Subject: bug#8531: 24.0.50;
Date: Mon, 08 Dec 2014 01:34:12 -0800	[thread overview]
Message-ID: <803b223f5dd871db67cab3b46e8b6d3a@samertm.com> (raw)
In-Reply-To: <8762q8xe3i.fsf@gmail.com>

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?

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 \\<RET> 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 \\<RET> 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!"






  parent reply	other threads:[~2014-12-08  9:34 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-21  7:23 bug#8531: 24.0.50; shell-quote-argument shouldn't escape special characters Thierry Volpiatto
2011-04-21 10:33 ` Eli Zaretskii
2011-04-21 12:10   ` Thierry Volpiatto
2011-04-21 13:04     ` Eli Zaretskii
2011-04-21 13:31       ` Thierry Volpiatto
2011-04-21 13:58         ` Eli Zaretskii
2011-04-21 16:34           ` Thierry Volpiatto
2011-04-21 23:14             ` Glenn Morris
2011-04-22  5:53               ` Eli Zaretskii
2011-04-22  7:10                 ` Glenn Morris
2011-04-22  8:03                   ` Eli Zaretskii
2011-04-22  6:03               ` Thierry Volpiatto
2011-04-22  6:15                 ` Eli Zaretskii
2011-04-22  9:21                   ` Thierry Volpiatto
2014-12-08  9:34 ` samer [this message]
2014-12-08 18:46   ` bug#8531: 24.0.50; Stefan Monnier
2014-12-09  0:15     ` samer
2014-12-09  0:41       ` Lars Magne Ingebrigtsen
2014-12-09  2:11         ` samer
2014-12-09  2:14           ` Lars Magne Ingebrigtsen
2014-12-09 22:11           ` samer
2014-12-09 22:21             ` Lars Magne Ingebrigtsen
2014-12-09 22:30               ` samer
2014-12-08 16:48 ` bug#8531: 24.0.50; shell-quote-argument shouldn't escape special characters samer
2015-02-24 10:51 ` bug#8531: 24.0.50; Samer Masterson
2015-03-03 15:52   ` Eli Zaretskii
     [not found]     ` <1425472710.1450.3@mail.samertm.com>
     [not found]       ` <83h9u0psn8.fsf@gnu.org>
2015-04-06  3:50         ` Samer Masterson
2015-03-15 11:58 ` Samer Masterson
2015-04-09  2:32   ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=803b223f5dd871db67cab3b46e8b6d3a@samertm.com \
    --to=samer@samertm.com \
    --cc=8531@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.