]> git.eshelyaron.com Git - emacs.git/commitdiff
Error if --eval arg has text beyond 1 expression
authorNoam Postavsky <npostavs@gmail.com>
Sun, 3 Jul 2016 00:26:35 +0000 (20:26 -0400)
committerNoam Postavsky <npostavs@gmail.com>
Sat, 6 Aug 2016 20:16:02 +0000 (16:16 -0400)
* lisp/startup.el (command-line-1): If --eval argument has more data
than constitutes a single Lisp expression, signal an error (Bug #23159).

lisp/startup.el

index 761e69e03b1da8a6d833cb56806d101b0533393b..fcdc376c5ff86af75eb5644f007af94589b6e758 100644 (file)
@@ -2360,7 +2360,14 @@ nil default-directory" name)
 
                     ((member argi '("-eval" "-execute"))
                      (setq inhibit-startup-screen t)
-                     (eval (read (or argval (pop command-line-args-left)))))
+                     (let* ((str-expr (or argval (pop command-line-args-left)))
+                            (read-data (read-from-string str-expr))
+                            (expr (car read-data))
+                            (end (cdr read-data)))
+                       (unless (= end (length str-expr))
+                         (error "Trailing garbage following expression: %s"
+                                (substring str-expr end)))
+                       (eval expr)))
 
                     ((member argi '("-L" "-directory"))
                      ;; -L :/foo adds /foo to the _end_ of load-path.