emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Small fix in `shell--unquote&requote-argument' - please review


From: Filipp Gunbin
Subject: Small fix in `shell--unquote&requote-argument' - please review
Date: Wed, 31 Aug 2016 02:24:52 +0300

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)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]