unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#36219: GNU Emacs 26.1 --eval rejects trailing whitespace
@ 2019-06-15  2:39 �o�ӡ����Yһ��
  2019-06-15 13:33 ` Noam Postavsky
  0 siblings, 1 reply; 6+ messages in thread
From: �o�ӡ����Yһ�� @ 2019-06-15  2:39 UTC (permalink / raw)
  To: 36219

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb18030", Size: 2117 bytes --]

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.

===
$ Emacs --batch --eval "1 2"
Trailing garbage following expression:  2
===

However if there's trailing white space even single valid expression would be
rejected after the fix.

===
$ Emacs --batch --eval "1  "
Trailing garbage following expression:   
===

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

===
#!/bin/sh
# Tangle files with Org mode
#
emacs -Q --batch --eval "
    (progn
      (require 'ob-tangle)
      (dolist (file command-line-args-left)
        (with-current-buffer (find-file-noselect file)
          (org-babel-tangle))))
  " "$@"
===

From the proposal in bug#23159
https://lists.gnu.org/archive/html/bug-gnu-emacs/2016-07/msg00097.html

> I¡¯d suggest (error =22Trailing garbage following expression¡±)
> for consistency with the eval-expression function.
>
>                 Peace
>                         ¡ªDevon


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.

--- lisp/startup.el.old	2019-06-15 10:31:59.000000000 +0800
+++ lisp/startup.el	2019-06-15 10:34:51.000000000 +0800
@@ -2360,7 +2360,9 @@
 
                     ((member argi '("-eval" "-execute"))
                      (setq inhibit-startup-screen t)
-                     (let* ((str-expr (or argval (pop command-line-args-left)))
+                     (let* ((str-expr
+                             (string-trim-right
+                              (or argval (pop command-line-args-left))))
                             (read-data (read-from-string str-expr))
                             (expr (car read-data))
                             (end (cdr read-data)))

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-06-15 21:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-15  2:39 bug#36219: GNU Emacs 26.1 --eval rejects trailing whitespace �o�ӡ����Yһ��
2019-06-15 13:33 ` Noam Postavsky
2019-06-15 13:54   ` Eli Zaretskii
2019-06-15 14:06     ` Noam Postavsky
2019-06-15 14:24       ` Eli Zaretskii
2019-06-15 21:46         ` Noam Postavsky

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).