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.

Full log


View this message in rfc822 format

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





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

Previous Next


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