[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#36219: GNU Emacs 26.1 --eval rejects trailing whitespace
From: |
Noam Postavsky |
Subject: |
bug#36219: GNU Emacs 26.1 --eval rejects trailing whitespace |
Date: |
Sat, 15 Jun 2019 09:33:10 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) |
severity 36219 minor
tags 36219 + patch
quit
<andpuke@foxmail.com> writes:
> Since commit a90d5e6309c0306d931d398506b242c3eb4f40d7 which fixes bug #23159
> the `--eval' command line option signals (error "Trailing garbage following
> expression: %s") on more than one expression recevied.
> This causes some old shell script snippets which has trailing newline for
> formatting no longer works, such as the follow script from
> https://orgmode.org/manual/Batch-Execution.html#Batch-Execution
> Since `eval-expression' accepts additional white space and newlines after a
> single expression, this mismatch behavior of `--eval' should be considered as
> a
> bug.
>
> My proposed fix is apply `string-trim-right` to received string of expression.
>
I think I'd prefer checking the trailing garbage for whitespace, which
is what eval-expression does. See following patch:
>From c067e710eb7d6e1606f0cdd76e37fe84104d33d8 Mon Sep 17 00:00:00 2001
From: Noam Postavsky <npostavs@gmail.com>
Date: Sat, 15 Jun 2019 08:40:23 -0400
Subject: [PATCH] Allow trailing whitespace in --eval argument (Bug#36219)
* lisp/startup.el (command-line-1): Don't complain about trailing
garbage if it's only space, tab, or newline characters.
---
lisp/startup.el | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/lisp/startup.el b/lisp/startup.el
index 32051c232c..f5463f2c93 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -2376,7 +2376,9 @@ (defun command-line-1 (args-left)
(read-data (read-from-string str-expr))
(expr (car read-data))
(end (cdr read-data)))
- (unless (= end (length str-expr))
+ ;; Allow same trailing chars as minibuf.c's
+ ;; `string_to_object'.
+ (unless (string-match-p "[\s\t\n]*\\'" str-expr end)
(error "Trailing garbage following expression: %s"
(substring str-expr end)))
(eval expr)))
--
2.11.0
This is a regression from Emacs 25, and the fix looks pretty safe to me;
although the bug isn't especially severe. Should it go to emacs-26?