From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Noam Postavsky Newsgroups: gmane.emacs.bugs Subject: bug#36219: GNU Emacs 26.1 --eval rejects trailing whitespace Date: Sat, 15 Jun 2019 09:33:10 -0400 Message-ID: <87ftobynvt.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="73020"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) Cc: 36219@debbugs.gnu.org To: Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jun 15 15:34:13 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hc8ou-000Iol-H6 for geb-bug-gnu-emacs@m.gmane.org; Sat, 15 Jun 2019 15:34:12 +0200 Original-Received: from localhost ([::1]:60616 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hc8ot-0006It-Ip for geb-bug-gnu-emacs@m.gmane.org; Sat, 15 Jun 2019 09:34:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42779) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hc8ol-0006Fe-TQ for bug-gnu-emacs@gnu.org; Sat, 15 Jun 2019 09:34:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hc8ok-0008Gr-JL for bug-gnu-emacs@gnu.org; Sat, 15 Jun 2019 09:34:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:53183) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hc8ok-0008Gd-Dz for bug-gnu-emacs@gnu.org; Sat, 15 Jun 2019 09:34:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hc8ok-0006N3-9C for bug-gnu-emacs@gnu.org; Sat, 15 Jun 2019 09:34:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Noam Postavsky Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 15 Jun 2019 13:34:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 36219 X-GNU-PR-Package: emacs Original-Received: via spool by 36219-submit@debbugs.gnu.org id=B36219.156060560424444 (code B ref 36219); Sat, 15 Jun 2019 13:34:02 +0000 Original-Received: (at 36219) by debbugs.gnu.org; 15 Jun 2019 13:33:24 +0000 Original-Received: from localhost ([127.0.0.1]:38494 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hc8o8-0006M7-0a for submit@debbugs.gnu.org; Sat, 15 Jun 2019 09:33:24 -0400 Original-Received: from mail-io1-f52.google.com ([209.85.166.52]:32926) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hc8o2-0006Lk-3f; Sat, 15 Jun 2019 09:33:21 -0400 Original-Received: by mail-io1-f52.google.com with SMTP id u13so11982910iop.0; Sat, 15 Jun 2019 06:33:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:references:user-agent:date :message-id:mime-version; bh=fleUDj/o89A/MEuEKMXnK8Sp/ejP8To+TIaNT1uVqT0=; b=n68ZSj79fN0vjzKL8Iduw2BMJCe34dsn0dyJUHdHKESacgRfb97Qxnou+C+Lp5NxC3 Ky0OZdKTewtgyey7Ot80WWhpM3O46zmUA/q8VQtS9pwTMwFaV7vAUwZJnTsiKdd3VOtx iPD2OCs7MccewXfn4dCdU95ugSMAZ93K+i1VSkIO++EMmRYdoUkdCR6ioAKmeLpqe96V Y4V1Ttmt/5Q8d2Pco1/aWiEMoJCnvgKVsVLoZMJqFfaytyIXVjoiMVbmuguhhImUL27s KhSr3MUit7ExIFcmB3Cn+TJOXszSFFYTBLMr1WxDt+IN5Cf7XwdaDo3hzC1wKsykhJjf 330g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references :user-agent:date:message-id:mime-version; bh=fleUDj/o89A/MEuEKMXnK8Sp/ejP8To+TIaNT1uVqT0=; b=MouYloj6ghCyLm7/yyFqD9ICzNiMEqCLyi3IThUZksY+IYb222pCNzDWelGcquXdaD hHk9whB4HtXXeBaVt+yHHVwXuONvW1sxbZEU4Arx2EsWbZX1R2uuXnZ2KmU493V3O3Ga WGR0FwN7IBl6SQFx9rD0IpTKzy1On2tZ+2Trn/vnNdlJlG6eSz/+rFCPUwCvslobdx9C d3v5r6KDlZihOf8inUFp12aunBDIQ/+j5mdk7EnFZxLy9ZBjFu5lXqK3cplfCp3h+BBL 44MpVhCXNvSwYZCkydCeQoCajVly776+10xL+X3/q5e+QWpPRu+eJeWJEnel1nlA5b6H njzg== X-Gm-Message-State: APjAAAUnVfQOxX9cPn8EJFgnON/VdKEkEe2n9h9fRs4MjKrOnYzU6JK1 E8gnzOYQrrFXuAnb63Bfz6Tb0NMC X-Google-Smtp-Source: APXvYqwNs/ciz4Wk7yRf4r7jjUlg1SIScsxtnHU4RichRR8IeLhB67HGuec++CfguzdWyecmoOaJpg== X-Received: by 2002:a02:b68f:: with SMTP id i15mr66096179jam.107.1560605592147; Sat, 15 Jun 2019 06:33:12 -0700 (PDT) Original-Received: from minid (cbl-45-2-119-34.yyz.frontiernetworks.ca. [45.2.119.34]) by smtp.gmail.com with ESMTPSA id 15sm7505367ioe.46.2019.06.15.06.33.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 15 Jun 2019 06:33:11 -0700 (PDT) In-Reply-To: (andpuke@foxmail.com's message of "Sat, 15 Jun 2019 10:39:10 +0800") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:160612 Archived-At: --=-=-= Content-Type: text/plain severity 36219 minor tags 36219 + patch quit 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: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-Allow-trailing-whitespace-in-eval-argument-Bug-36219.patch Content-Description: patch >From c067e710eb7d6e1606f0cdd76e37fe84104d33d8 Mon Sep 17 00:00:00 2001 From: Noam Postavsky 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 --=-=-= Content-Type: text/plain 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? --=-=-=--