GNU bug report logs - #23159
24.5; --eval bug

Previous Next

Package: emacs;

Reported by: "Devon Sean McCullough" <Emacs-Hacker2016 <at> jovi.net>

Date: Wed, 30 Mar 2016 09:23:01 UTC

Severity: minor

Tags: patch

Found in version 24.5

Fixed in version 26.1

Done: npostavs <at> users.sourceforge.net

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 23159 in the body.
You can then email your comments to 23159 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#23159; Package emacs. (Wed, 30 Mar 2016 09:23:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to "Devon Sean McCullough" <Emacs-Hacker2016 <at> jovi.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 30 Mar 2016 09:23:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: "Devon Sean McCullough" <Emacs-Hacker2016 <at> jovi.net>
To: bug-gnu-emacs <at> gnu.org
Subject: 24.5; --eval bug
Date: Tue, 29 Mar 2016 21:40:37 -0500
MacOSX$ Open -n /Applications/Emacs.app --args -Q --eval "(print 'foo)
(print 'bar)"
should either report an error or print foo bar.
The current buggy behavior silently ignores part of the argument.

		Peace
			--Devon

In GNU Emacs 24.5.1 (x86_64-apple-darwin13.4.0, NS apple-appkit-1265.21)
 of 2015-04-11 on builder10-9.porkrind.org
Windowing system distributor `Apple', version 10.3.1404
Configured using:
 `configure --with-ns '--enable-locallisppath=/Library/Application
 Support/Emacs/${version}/site-lisp:/Library/Application
 Support/Emacs/site-lisp''

Important settings:
  locale-coding-system: utf-8-unix

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.

foo

Load-path shadows:
None found.

Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
easymenu mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums
mm-util help-fns mail-prsvr mail-utils time-date tooltip electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel ns-win tool-bar dnd
fontset image regexp-opt fringe tabulated-list newcomment lisp-mode
prog-mode register page menu-bar rfn-eshadow timer select scroll-bar
mouse jit-lock font-lock syntax facemenu font-core frame cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev
minibuffer nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote make-network-process
cocoa ns multi-tty emacs)

Memory information:
((conses 16 71360 5445)
 (symbols 48 17206 0)
 (miscs 40 35 102)
 (strings 32 9707 4708)
 (string-bytes 1 257299)
 (vectors 16 8934)
 (vector-slots 8 371822 19184)
 (floats 8 53 157)
 (intervals 56 162 0)
 (buffers 960 11))





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#23159; Package emacs. (Wed, 30 Mar 2016 15:30:01 GMT) Full text and rfc822 format available.

Message #8 received at 23159 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: "Devon Sean McCullough" <Emacs-Hacker2016 <at> jovi.net>
Cc: 23159 <at> debbugs.gnu.org
Subject: Re: bug#23159: 24.5; --eval bug
Date: Wed, 30 Mar 2016 18:28:54 +0300
> Date: Tue, 29 Mar 2016 21:40:37 -0500
> From: "Devon Sean McCullough" <Emacs-Hacker2016 <at> jovi.net>
> 
> MacOSX$ Open -n /Applications/Emacs.app --args -Q --eval "(print 'foo)
> (print 'bar)"
> should either report an error or print foo bar.
> The current buggy behavior silently ignores part of the argument.

I think this is expected.  The manual says:

  ‘--eval=EXPRESSION’
  ‘--execute=EXPRESSION’
       Evaluate Lisp expression EXPRESSION.

It evaluates a single Lisp expression.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#23159; Package emacs. (Sun, 03 Jul 2016 00:31:02 GMT) Full text and rfc822 format available.

Message #11 received at 23159 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: Devon Sean McCullough <Emacs-Hacker2016 <at> jovi.net>, 23159 <at> debbugs.gnu.org
Subject: Re: bug#23159: 24.5; --eval bug
Date: Sat, 02 Jul 2016 20:30:37 -0400
[Message part 1 (text/plain, inline)]
tags 23159 patch
quit

Eli Zaretskii <eliz <at> gnu.org> writes:

>> Date: Tue, 29 Mar 2016 21:40:37 -0500
>> From: "Devon Sean McCullough" <Emacs-Hacker2016 <at> jovi.net>
>> 
>> MacOSX$ Open -n /Applications/Emacs.app --args -Q --eval "(print 'foo)
>> (print 'bar)"
>> should either report an error or print foo bar.
>> The current buggy behavior silently ignores part of the argument.
>
> I think this is expected.  The manual says:
>
>   ‘--eval=EXPRESSION’
>   ‘--execute=EXPRESSION’
>        Evaluate Lisp expression EXPRESSION.
>
> It evaluates a single Lisp expression.

If we get more than that, a warning seems appropriate.

[v1-0001-Warn-if-eval-arg-has-text-beyond-1-expression.patch (text/x-diff, inline)]
From c9730b47893678b2283590c269ad33998a8a430a Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Sat, 2 Jul 2016 20:26:35 -0400
Subject: [PATCH v1] Warn if --eval arg has text beyond 1 expression

* lisp/startup.el (command-line-1): If --eval argument has more data
than constitutes a single Lisp expression, print warning (Bug #23159).
---
 lisp/startup.el | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lisp/startup.el b/lisp/startup.el
index 761e69e..9f04a00 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -2360,7 +2360,15 @@ command-line-1
 
                     ((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)))
+                       (eval expr)
+                       (unless (= end (length str-expr))
+                         (lwarn '(command-line eval) :warning
+                                "Garbage at the end of expression: %s"
+                                (substring str-expr end)))))
 
                     ((member argi '("-L" "-directory"))
                      ;; -L :/foo adds /foo to the _end_ of load-path.
-- 
2.8.0


Added tag(s) patch. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Sun, 03 Jul 2016 00:31:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#23159; Package emacs. (Sun, 03 Jul 2016 15:44:02 GMT) Full text and rfc822 format available.

Message #16 received at 23159 <at> debbugs.gnu.org (full text, mbox):

From: Devon Sean McCullough <devon2016 <at> jovi.net>
To: npostavs <at> users.sourceforge.net
Cc: Devon Sean McCullough <Emacs-Hacker2016 <at> jovi.net>,
 Eli Zaretskii <eliz <at> gnu.org>, 23159 <at> debbugs.gnu.org
Subject: Re: bug#23159: 24.5; --eval bug
Date: Sun, 3 Jul 2016 06:25:06 -0400
I’d suggest (error "Trailing garbage following expression”)
for consistency with the eval-expression function.

		Peace
			—Devon

> On Jul 2, 2016, at 8:30 PM, npostavs <at> users.sourceforge.net wrote:
> 
> tags 23159 patch
> quit
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
>>> Date: Tue, 29 Mar 2016 21:40:37 -0500
>>> From: "Devon Sean McCullough" <Emacs-Hacker2016 <at> jovi.net>
>>> 
>>> MacOSX$ Open -n /Applications/Emacs.app --args -Q --eval "(print 'foo)
>>> (print 'bar)"
>>> should either report an error or print foo bar.
>>> The current buggy behavior silently ignores part of the argument.
>> 
>> I think this is expected.  The manual says:
>> 
>>  ‘--eval=EXPRESSION’
>>  ‘--execute=EXPRESSION’
>>       Evaluate Lisp expression EXPRESSION.
>> 
>> It evaluates a single Lisp expression.
> 
> If we get more than that, a warning seems appropriate.
> 
> From c9730b47893678b2283590c269ad33998a8a430a Mon Sep 17 00:00:00 2001
> From: Noam Postavsky <npostavs <at> gmail.com>
> Date: Sat, 2 Jul 2016 20:26:35 -0400
> Subject: [PATCH v1] Warn if --eval arg has text beyond 1 expression
> 
> * lisp/startup.el (command-line-1): If --eval argument has more data
> than constitutes a single Lisp expression, print warning (Bug #23159).
> ---
> lisp/startup.el | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/lisp/startup.el b/lisp/startup.el
> index 761e69e..9f04a00 100644
> --- a/lisp/startup.el
> +++ b/lisp/startup.el
> @@ -2360,7 +2360,15 @@ command-line-1
> 
>                     ((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)))
> +                       (eval expr)
> +                       (unless (= end (length str-expr))
> +                         (lwarn '(command-line eval) :warning
> +                                "Garbage at the end of expression: %s"
> +                                (substring str-expr end)))))
> 
>                     ((member argi '("-L" "-directory"))
>                      ;; -L :/foo adds /foo to the _end_ of load-path.
> -- 
> 2.8.0
> 





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#23159; Package emacs. (Sun, 03 Jul 2016 18:55:02 GMT) Full text and rfc822 format available.

Message #19 received at 23159 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Devon Sean McCullough <devon2016 <at> jovi.net>
Cc: Devon Sean McCullough <Emacs-Hacker2016 <at> jovi.net>,
 Eli Zaretskii <eliz <at> gnu.org>, 23159 <at> debbugs.gnu.org
Subject: Re: bug#23159: 24.5; --eval bug
Date: Sun, 03 Jul 2016 14:54:32 -0400
[Message part 1 (text/plain, inline)]
Devon Sean McCullough <devon2016 <at> jovi.net> writes:

> I’d suggest (error "Trailing garbage following expression”)
> for consistency with the eval-expression function.

Makes sense.

[v2-0001-Warn-if-eval-arg-has-text-beyond-1-expression.patch (text/x-diff, inline)]
From 5990021e37069a8a03181dc5167f0e94d748981e Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Sat, 2 Jul 2016 20:26:35 -0400
Subject: [PATCH v2] Warn if --eval arg has text beyond 1 expression

* lisp/startup.el (command-line-1): If --eval argument has more data
than constitutes a single Lisp expression, print warning (Bug #23159).
---
 lisp/startup.el | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/lisp/startup.el b/lisp/startup.el
index 761e69e..75ae9f9 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -2360,7 +2360,15 @@ command-line-1
 
                     ((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)))
+                       (eval expr)
+                       (unless (= end (length str-expr))
+                         (lwarn '(command-line eval) :warning
+                                "Trailing garbage following expression: %s"
+                                (substring str-expr end)))))
 
                     ((member argi '("-L" "-directory"))
                      ;; -L :/foo adds /foo to the _end_ of load-path.
-- 
2.8.0


Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#23159; Package emacs. (Thu, 07 Jul 2016 01:13:02 GMT) Full text and rfc822 format available.

Message #22 received at 23159 <at> debbugs.gnu.org (full text, mbox):

From: npostavs <at> users.sourceforge.net
To: Devon Sean McCullough <devon2016 <at> jovi.net>
Cc: Devon Sean McCullough <Emacs-Hacker2016 <at> jovi.net>,
 Eli Zaretskii <eliz <at> gnu.org>, 23159 <at> debbugs.gnu.org
Subject: Re: bug#23159: 24.5; --eval bug
Date: Wed, 06 Jul 2016 21:12:44 -0400
[Message part 1 (text/plain, inline)]
npostavs <at> users.sourceforge.net writes:

> Devon Sean McCullough <devon2016 <at> jovi.net> writes:
>
>> I’d suggest (error "Trailing garbage following expression”)
>> for consistency with the eval-expression function.
>
> Makes sense.

Oops, I didn't actually change warning to error.  One more try.

[v3-0001-Error-if-eval-arg-has-text-beyond-1-expression.patch (text/x-diff, inline)]
From cf22d9210d09b936d8f734aedb6a76e12830c690 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs <at> gmail.com>
Date: Sat, 2 Jul 2016 20:26:35 -0400
Subject: [PATCH v3] Error if --eval arg has text beyond 1 expression

* 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 | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/lisp/startup.el b/lisp/startup.el
index 761e69e..fcdc376 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -2360,7 +2360,14 @@ command-line-1
 
                     ((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.
-- 
2.8.0


bug marked as fixed in version 25.2, send any further explanations to 23159 <at> debbugs.gnu.org and "Devon Sean McCullough" <Emacs-Hacker2016 <at> jovi.net> Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Sat, 06 Aug 2016 20:17:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 04 Sep 2016 11:24:04 GMT) Full text and rfc822 format available.

bug unarchived. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sun, 04 Dec 2016 02:50:11 GMT) Full text and rfc822 format available.

bug Marked as fixed in versions 26.1. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sun, 04 Dec 2016 02:50:11 GMT) Full text and rfc822 format available.

bug No longer marked as fixed in versions 25.2. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Sun, 04 Dec 2016 02:50:11 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 01 Jan 2017 12:24:19 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 167 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.