From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Prof Jayanth R Varma Newsgroups: gmane.emacs.bugs Subject: bug#36331: 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@JRVLAPTOP.i-did-not-set--mail-host-address--so-tickle-me> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="245622"; mail-complaints-to="usenet@blaine.gmane.org" To: 36331@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jun 22 17:14:50 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 1hehj7-0011kf-GW for geb-bug-gnu-emacs@m.gmane.org; Sat, 22 Jun 2019 17:14:49 +0200 Original-Received: from localhost ([::1]:41206 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hehj6-0007du-FZ for geb-bug-gnu-emacs@m.gmane.org; Sat, 22 Jun 2019 11:14:48 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35689) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hehiO-00071Z-BM for bug-gnu-emacs@gnu.org; Sat, 22 Jun 2019 11:14:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hehiM-0000bX-SN for bug-gnu-emacs@gnu.org; Sat, 22 Jun 2019 11:14:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:38868) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hehiM-0000bM-Ot for bug-gnu-emacs@gnu.org; Sat, 22 Jun 2019 11:14:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hehiM-0003kj-HT for bug-gnu-emacs@gnu.org; Sat, 22 Jun 2019 11:14:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Prof Jayanth R Varma Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 22 Jun 2019 15:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 36331 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.156121643614403 (code B ref -1); Sat, 22 Jun 2019 15:14:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 22 Jun 2019 15:13:56 +0000 Original-Received: from localhost ([127.0.0.1]:52412 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hehiE-0003k5-PD for submit@debbugs.gnu.org; Sat, 22 Jun 2019 11:13:56 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:54953) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hefHk-0001Ar-2m for submit@debbugs.gnu.org; Sat, 22 Jun 2019 08:38:24 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:35023) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hefHi-0007Dg-Cg for bug-gnu-emacs@gnu.org; Sat, 22 Jun 2019 08:38:23 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hefHg-0000ie-QJ for bug-gnu-emacs@gnu.org; Sat, 22 Jun 2019 08:38:22 -0400 Original-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 ) id 1hefHg-0000dy-Ja for bug-gnu-emacs@gnu.org; Sat, 22 Jun 2019 08:38:20 -0400 Original-Received: by mail-pf1-x441.google.com with SMTP id d126so4958578pfd.2 for ; 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) Original-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 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 22 Jun 2019 05:38:15 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Mailman-Approved-At: Sat, 22 Jun 2019 11:13:52 -0400 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:161035 Archived-At: 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