emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/shell-command+ a891756 04/13: Detect errors during toke


From: Stefan Monnier
Subject: [elpa] externals/shell-command+ a891756 04/13: Detect errors during tokenization
Date: Sun, 23 May 2021 13:41:26 -0400 (EDT)

branch: externals/shell-command+
commit a8917560d6370d88aef39ce27a458070745d3ce2
Author: Philip K <philipk@posteo.net>
Commit: Philip K <philipk@posteo.net>

    Detect errors during tokenization
---
 shell-command+.el | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/shell-command+.el b/shell-command+.el
index 4e0bfba..ab8fe14 100644
--- a/shell-command+.el
+++ b/shell-command+.el
@@ -138,13 +138,15 @@ the command string"
   "Return list of tokens of COMMAND."
   (let ((pos 0) tokens)
     (while (string-match
-            (rx (* space)
+            (rx bos (* space)
                 (or (: ?\" (group-n 1 (* (not ?\"))) ?\")
-                    (: (group-n 1 (+ (not (any ?\" ?\s)))))))
-            command pos)
-      (push (match-string 1 command)
+                    (: (group-n 1 (+ (not (any ?\" space)))))))
+            (substring command pos))
+      (push (match-string 1 (substring command pos))
             tokens)
-      (setq pos (match-end 0)))
+      (setq pos (+ pos (match-end 0))))
+    (unless (= pos (length command))
+      (error "Tokenization error at %s" (substring command pos)))
     (nreverse tokens)))
 
 (defun shell-command+-cmd-grep (command)



reply via email to

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