[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#23159: 24.5; --eval bug
From: |
Devon Sean McCullough |
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@users.sourceforge.net wrote:
>
> tags 23159 patch
> quit
>
> Eli Zaretskii <eliz@gnu.org> writes:
>
>>> Date: Tue, 29 Mar 2016 21:40:37 -0500
>>> From: "Devon Sean McCullough" <Emacs-Hacker2016@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@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
>