unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Small fix in `shell--unquote&requote-argument' - please review
@ 2016-08-30 23:24 Filipp Gunbin
  2016-08-31 13:27 ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: Filipp Gunbin @ 2016-08-30 23:24 UTC (permalink / raw)
  To: emacs-devel

Hi, here's what this patch does:

1. match is always less than (length str), so I guess they meant
`((< (1+ match) (length qstr))'.

2. If `string-match' searching for ending single quote failed,
`(match-string 0)' is still called - be careful not to do this.

Filipp


diff --git a/lisp/shell.el b/lisp/shell.el
index 1f019f2..1dc4d26 100644
--- a/lisp/shell.el
+++ b/lisp/shell.el
@@ -384,11 +384,13 @@ shell--unquote&requote-argument
        ((eq (aref qstr match) ?\") (setq dquotes (not dquotes)))
        ((eq (aref qstr match) ?\')
         (cond
+         ;; just text if inside double quotes
          (dquotes (funcall push "'" (match-end 0)))
-         ((< match (1+ (length qstr)))
-          (let ((end (string-match "'" qstr (1+ match))))
-            (funcall push (substring qstr (1+ match) end)
-                     (or end (length qstr)))))
+         ((< (1+ match) (length qstr))
+          (let ((end (or (string-match "'" qstr (1+ match))
+                         (error "No matching single quote"))))
+            (funcall push (substring qstr (1+ match) end) end)))
+         ;; ignore if at the end of string
          (t nil)))
        (t (error "Unexpected case in shell--unquote&requote-argument!")))
       (setq qpos (match-end 0)))



^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-10-27 12:41 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-30 23:24 Small fix in `shell--unquote&requote-argument' - please review Filipp Gunbin
2016-08-31 13:27 ` Stefan Monnier
2016-09-01 13:15   ` Filipp Gunbin
2016-09-01 13:39     ` Stefan Monnier
2016-09-01 14:35       ` Filipp Gunbin
2016-09-08 19:22         ` Filipp Gunbin
2016-09-08 20:23           ` Stefan Monnier
2016-10-26 18:32           ` Stefan Monnier
2016-10-27 12:41             ` Filipp Gunbin

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).