GNU bug report logs - #18745
24.3; MS Windows, `call-process-shell-command' fails on `shell-quote-argument'ed bat file with quoted args

Previous Next

Package: emacs;

Reported by: Noam Postavsky <npostavs <at> users.sourceforge.net>

Date: Thu, 16 Oct 2014 04:35:01 UTC

Severity: minor

Found in versions 25.0.50, 24.3

Done: Juanma Barranquero <lekktu <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


Message #100 received at 18745 <at> debbugs.gnu.org (full text, mbox):

From: Juanma Barranquero <lekktu <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 18745 <at> debbugs.gnu.org
Subject: Re: bug#18745:
Date: Sun, 1 Nov 2015 00:20:34 +0100
[Message part 1 (text/plain, inline)]
On Fri, Oct 30, 2015 at 9:10 PM, Eli Zaretskii <eliz <at> gnu.org> wrote:

> If the batch says
>
>   cmd /c echo arg1 = %1, arg2 = %2
>
> i.e. invokes cmd.exe from the batch file, does the test still fail?

With

            (with-temp-file batfile
              (insert "@cmd /c echo arg1 = %1, arg2 = %2\n"))

it still works on cmd.exe, fails on tcc.exe

> If it still fails, I think making the test more tolerant of the
> trailing whitespace is IMO a better alternative than letting it fail.
> After all, that trailing space is not what we are testing there.

Something like this, you mean?

diff --git a/test/automated/process-tests.el
b/test/automated/process-tests.el
index 1dab615..58a2de7 100644
--- a/test/automated/process-tests.el
+++ b/test/automated/process-tests.el
@@ -61,15 +61,15 @@ process-test-sentinel-wait-function-working-p
             ;; to force quoting.
             (setq batfile (make-temp-file "echo args" nil ".bat"))
             (with-temp-file batfile
-              (insert "@echo arg1 = %1, arg2 = %2\n"))
+              (insert "@echo arg1=%1, arg2=%2\n"))
             (with-temp-buffer
               (call-process batfile nil '(t t) t "x &y")
-              (should (string= (buffer-string) "arg1 = \"x &y\", arg2 =
\n")))
+              (should (string= (buffer-string) "arg1=\"x &y\", arg2=\n")))
             (with-temp-buffer
               (call-process-shell-command
                (mapconcat #'shell-quote-argument (list batfile "x &y") " ")
                nil '(t t) t)
-              (should (string= (buffer-string) "arg1 = \"x &y\", arg2 =
\n"))))
+              (should (string= (buffer-string) "arg1=\"x &y\", arg2=\n"))))
         (when batfile (delete-file batfile))))))

 (ert-deftest process-test-stderr-buffer ()
warning: LF will be replaced by CRLF in test/automated/process-tests.el.
The file will have its original line endings in your working directory.



BTW, curiously, the stderr-related tests in the same test file
(process-test-stderr-buffer and process-test-stderr-filter) fail sometimes.
Much more frequently on TCC than CMD, but they also fail in CMD, as in
these examples:

C:\...\automated> ..\..\src\emacs.exe -Q -batch -l ert -l process-tests.elc
-f ert-run-tests-batch-and-exit
Running 5 tests (2015-10-31 23:35:46+0100)
   passed  1/5  process-test-quoted-batfile
   passed  2/5  process-test-sentinel-accept-process-output
   passed  3/5  process-test-sentinel-sit-for
Test process-test-stderr-buffer backtrace:
  #[nil "\306\307C \310 \311 \3121 \313\216\314      \"\211 )0\202 \210
  ert--run-test-internal([cl-struct-ert--test-execution-info [cl-struc
  ert-run-test([cl-struct-ert-test process-test-stderr-buffer nil #[ni
  ert-run-or-rerun-test([cl-struct-ert--stats t [[cl-struct-ert-test p
  ert-run-tests(t #[385 "\306 \307\"\203G \211\211G\310U\203 \211@\20
  ert-run-tests-batch(nil)
  ert-run-tests-batch-and-exit()
  command-line-1(("-l" "ert" "-l" "process-tests.elc" "-f" "ert-run-te
  command-line()
  normal-top-level()
Test process-test-stderr-buffer condition:
    (ert-test-failed
     ((should
       (with-current-buffer stderr-buffer
         (goto-char ...)
         (looking-at "hello stderr!")))
      :form
      (save-current-buffer
        (set-buffer stderr-buffer)
        (goto-char
         (point-min))
        (looking-at "hello stderr!"))
      :value nil))
   FAILED  4/5  process-test-stderr-buffer
   passed  5/5  process-test-stderr-filter

Ran 5 tests, 4 results as expected, 1 unexpected (2015-10-31 23:35:47+0100)

1 unexpected results:
   FAILED  process-test-stderr-buffer


C:\...\automated> ..\..\src\emacs.exe -Q -batch -l ert -l process-tests.elc
-f ert-run-tests-batch-and-exit
Running 5 tests (2015-10-31 23:34:42+0100)
   passed  1/5  process-test-quoted-batfile
   passed  2/5  process-test-sentinel-accept-process-output
   passed  3/5  process-test-sentinel-sit-for
   passed  4/5  process-test-stderr-buffer
Test process-test-stderr-filter backtrace:
  #[nil "\306\307C \310 \311 \3121 \313\216\314      \"\211 )0\202 \210
  ert--run-test-internal([cl-struct-ert--test-execution-info [cl-struc
  ert-run-test([cl-struct-ert-test process-test-stderr-filter nil #[ni
  ert-run-or-rerun-test([cl-struct-ert--stats t [[cl-struct-ert-test p
  ert-run-tests(t #[385 "\306 \307\"\203G \211\211G\310U\203 \211@\20
  ert-run-tests-batch(nil)
  ert-run-tests-batch-and-exit()
  command-line-1(("-l" "ert" "-l" "process-tests.elc" "-f" "ert-run-te
  command-line()
  normal-top-level()
Test process-test-stderr-filter condition:
    (ert-test-failed
     ((should stderr-sentinel-called)
      :form stderr-sentinel-called :value nil))
   FAILED  5/5  process-test-stderr-filter

Ran 5 tests, 4 results as expected, 1 unexpected (2015-10-31 23:34:43+0100)

1 unexpected results:
   FAILED  process-test-stderr-filter
[Message part 2 (text/html, inline)]

This bug report was last modified 9 years and 208 days ago.

Previous Next


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