GNU bug report logs - #36331
26.2; command run using dired-do-async-shell-command cannot take any input

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Prof Jayanth R Varma <jrvarma@HIDDEN> ; dated Sat, 22 Jun 2019 15:14:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 22 Jun 2019 15:13:56 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jun 22 11:13:56 2019
Received: from localhost ([127.0.0.1]:52412 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1hehiE-0003k5-PD
	for submit <at> debbugs.gnu.org; Sat, 22 Jun 2019 11:13:56 -0400
Received: from lists.gnu.org ([209.51.188.17]:54953)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <jrvarma@HIDDEN>) id 1hefHk-0001Ar-2m
 for submit <at> debbugs.gnu.org; Sat, 22 Jun 2019 08:38:24 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:35023)
 by lists.gnu.org with esmtp (Exim 4.86_2)
 (envelope-from <jrvarma@HIDDEN>) id 1hefHi-0007Dg-Cg
 for bug-gnu-emacs@HIDDEN; Sat, 22 Jun 2019 08:38:23 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM,
 URIBL_BLOCKED autolearn=disabled version=3.3.2
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <jrvarma@HIDDEN>) id 1hefHg-0000ie-QJ
 for bug-gnu-emacs@HIDDEN; Sat, 22 Jun 2019 08:38:22 -0400
Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]:34981)
 by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16)
 (Exim 4.71) (envelope-from <jrvarma@HIDDEN>) id 1hefHg-0000dy-Ja
 for bug-gnu-emacs@HIDDEN; Sat, 22 Jun 2019 08:38:20 -0400
Received: by mail-pf1-x441.google.com with SMTP id d126so4958578pfd.2
 for <bug-gnu-emacs@HIDDEN>; Sat, 22 Jun 2019 05:38:17 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=from:to:subject:date:message-id:mime-version;
 bh=2o18bdHosLkGRzbnhvkTC9XQM8szVmJuEl6xeKLG5ZY=;
 b=Ly4Y2GTLlqQ2tRL06/ZwyFGcIA7VaZK4U/nBObsRsyajt4sxEzE1GwdkKk3U5fwkDE
 NKBPZNAsclBjVcypdQwsjjFofjm/LIoaNqe3CoewKJmK1V5KQ7Bc7qD8UU+eeiW7cLwk
 i1yWkjeGcebVmfzfQXPwgnbpT4iAbPS48N/2wecnrW52ANZpXfj3ztWfsDanAQL7bQ1K
 tG00CpBCB3RpJNJElFy9yxkELumTsTri5QHeVCcDmZaLFqwh1HFYRShoUN04ov9UKi1v
 7Fzh18NUEs/1PQEF+l0jNsz0AtQaxZAzaRJXxuvlnlnkWu0uoCnbbRqlwUOLo8Wc4nGq
 yH6A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:subject:date:message-id:mime-version;
 bh=2o18bdHosLkGRzbnhvkTC9XQM8szVmJuEl6xeKLG5ZY=;
 b=lGyCyu3s7JLMN/XXShQ7jr56WxUPEPKGnRUTi3q6Bz2SZCsPzwSle+VFLwoNlLQQVU
 mQupeENBa/OptdolbibJeKJXE7/dCFI0zaXTBH3WIWV7+x01O88GZ21HmNIh2RswXhFC
 9G1Jej3CcqFGbvfMrMpRLXeWdCt+8jna4N1I+eUyxz67L4h7ykmcXVmsqKjplKeCrUUh
 znXmq1STcoiEA6b4uUHRlG8BEeMsk3B8COJCW57VQ3p9tC7WthMHBmO6HmqgijkgagMO
 SRTucEr3SsZibWkUegC6kjdbmnWw8cq3rqMcF5AgtTQ0ARRKkd3YV3GRkHZ5lJBfP0+h
 gmTg==
X-Gm-Message-State: APjAAAVCBxAwcCjXyhumaNRujotyS9zadX5pgTu3S5mwMnVV5h2Zw6ry
 xozLuuglDpA6ok4/PSxKfl+1iNb4
X-Google-Smtp-Source: APXvYqzf9V+4WTDtDPXeXJizIfpFj+gIMpXt0eWnXdcothag4gADpFRXLFAwl/baSB70PXBSBlQ0og==
X-Received: by 2002:a65:620d:: with SMTP id d13mr23770541pgv.109.1561207096511; 
 Sat, 22 Jun 2019 05:38:16 -0700 (PDT)
Received: from [127.0.1.1] ([14.139.123.52])
 by smtp.gmail.com with ESMTPSA id q144sm12719415pfc.103.2019.06.22.05.38.14
 for <bug-gnu-emacs@HIDDEN>
 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256);
 Sat, 22 Jun 2019 05:38:15 -0700 (PDT)
From: Prof Jayanth R Varma <jrvarma@HIDDEN> 
To: bug-gnu-emacs@HIDDEN
Subject: 26.2;
 command run using dired-do-async-shell-command cannot take any input
Date: Sat, 22 Jun 2019 18:07:59 +0530
Message-ID: <87mui9ztg8.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
 recognized.
X-Received-From: 2607:f8b0:4864:20::441
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
X-Mailman-Approved-At: Sat, 22 Jun 2019 11:13:52 -0400
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

dired-do-async-shell-command in dired-aux.el runs the command dired-shell-stuff-it which adds "&wait" to the command line. The source code explains the logic as follows:

                    ;; POSIX shells running a list of commands in the background
                    ;; (LIST = cmd_1 & [cmd_2 & ... cmd_i & ... cmd_N &])
                    ;; return once cmd_N ends, i.e., the shell does not
                    ;; wait for cmd_i to finish before executing cmd_i+1.
                    ;; That means, running (shell-command LIST) may not show
                    ;; the output of all the commands (Bug#23206).
                    ;; Add 'wait' to force those POSIX shells to wait until
                    ;; all commands finish.
                    (or (and parallel-in-background (not w32-shell)
                             "&wait")
                        "")))
Unfortunately, "parallel-in-background" is true even if there is only one command to be run (because there is only one selected file) as long as the command does not contain the character "*":

               (sequentially (string-match "[ \t]*;[ \t]*\\'" command))
               (parallel-in-background
                    (and in-background (not sequentially) (not (eq system-type 'ms-dos))))

As a result, the original single command now becomes a background command (by the addition of "& wait") and it loses access to standard input (it is implicitly run with an empty standard input). If the command asks for a confirmation prompt or a password, there is no way to provide that input. A simple though somewhat silly way to demonstrate the problem is by comparing the following two commands run using dired-do-async-shell-command on a single selected file (say 1.txt)

First command with "*" in the command line works as expected

       cat - * >2.txt

With this command, the *Async Shell Command* buffer waits for us to type in whatever lines that we want. When we terminate the input with Control-D (EOF), the command concatenates the inputs lines with 1.txt and writes the result to 2.txt.

Second command without "*" in the command line does NOT work as expected

       cat - >2.txt

With this command, the command runs without waiting for any input, and simply copies 1.txt to 2.txt because standard input is implicitly empty.

My suggestion is that the definition of "parallel-in-background" in dired-shell-stuff-it should include an additional test that the variable "file-list" contains more than one file.

-----------------------------------------------------

In GNU Emacs 26.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.8)
 of 2019-04-12 built on juergen
Windowing system distributor 'The X.Org Foundation', version 11.0.12005000
Configured using:
 'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib
 --localstatedir=/var --with-x-toolkit=gtk3 --with-xft --with-modules
 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong
 -fno-plt' CPPFLAGS=-D_FORTIFY_SOURCE=2
 LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now'

Configured features:
XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS GLIB
NOTIFY ACL GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB
TOOLKIT_SCROLL_BARS GTK3 X11 XDBE XIM MODULES THREADS LIBSYSTEMD LCMS2

Important settings:
  value of $LC_COLLATE: en_US.utf8
  value of $LC_MONETARY: en_IN.UTF-8
  value of $LC_NUMERIC: en_IN.UTF-8
  value of $LC_TIME: en_IN.UTF-8
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix





Acknowledgement sent to Prof Jayanth R Varma <jrvarma@HIDDEN> :
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#36331; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Mon, 25 Nov 2019 12:00:02 UTC

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