From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id wOrYIUIrgGZkQAAAqHPOHw:P1 (envelope-from ) for ; Sat, 29 Jun 2024 15:41:54 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id wOrYIUIrgGZkQAAAqHPOHw (envelope-from ) for ; Sat, 29 Jun 2024 17:41:54 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1719675714; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=gUbMTf+uEVefbwLFf/+TKIF0RD/PCWqhgj+V267lMUs=; b=pYln6JDFdkzEsjULZ2a1VOi17NbLXXqdvxzbjeu6NI6g8n3wIhPGO7FMofQny74PNOzCnl 0Yg2aDyTZJ3Eu6O92DF/irHYJL4tQnQry8sDsV2NJUCoWDu9h99M2W0PpxDE5V5i0U3oFE acJOLpieuSfEKn4S5mdAlHWowNgcKMGy2TrPjddnosoYfaTXxGgTtzdj1XFqV/wiy3c0D9 PDn0wKRdoWslXO/I/8F+TY4F8i0TeKDxCZ2AsfBOSyD/DZpU2VCknoIJ6M+dImQGfyKedc ybW8PQZuXD5635d7p7uYB18lZxES446bfzuU+RQf5S2brPMQtyORwER/8u9vHg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1719675714; a=rsa-sha256; cv=none; b=tkL9eXaHsGO5xiKTMrgsJOwdczteciWGGb79XWYSzXG3YIiMMrqdt4m+3FQF5Ml6+QfnQb Sb/LlLYblfZBoLfrB8XO3cwL1YPO5sxrdUyV6rL4gQR0gi866LTYuHXsBoyZ3RhkwjJ7yl DvNcx5ISZbv6uVcLLNygQZGEziyZhW8jqL+Fy+rhmCcOG7L0HeRQolHwLD7L3/SsI+VeOJ mmUk1JUa2Jo4aL5p0BlDlA0TMBoIxj1Efxb3qCyGf81z+1FSvCwMBs/hU2n4RYKuQbFCVl 0KwWkJNHXc9Ya64oItHsevi0b18vpblG79YjsfYijFgKMD5hUra9ELv6ycdxvg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 5E64573346 for ; Sat, 29 Jun 2024 17:41:54 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sNaC9-00071o-AP; Sat, 29 Jun 2024 11:40:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sNaC8-000712-At for emacs-orgmode@gnu.org; Sat, 29 Jun 2024 11:40:56 -0400 Received: from ciao.gmane.io ([116.202.254.214]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sNaC6-00026U-Kc for emacs-orgmode@gnu.org; Sat, 29 Jun 2024 11:40:56 -0400 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1sNaC2-0006uM-NS for emacs-orgmode@gnu.org; Sat, 29 Jun 2024 17:40:51 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: emacs-orgmode@gnu.org From: Max Nikulin Subject: Re: bash source code block: problem after ssh commands Date: Sat, 29 Jun 2024 22:40:41 +0700 Message-ID: References: <25912.63830.726070.953843@gargle.gargle.HOWL> <87bkcmlor9.fsf@t14.reltub.ca> <87o7gldb78.fsf@localhost> <25914.26693.101108.954656@gargle.gargle.HOWL> <87fs1xbis1.fsf@localhost> <25916.238.191509.652552@gargle.gargle.HOWL> <653f8a93.050a0220.f2202.5816@mx.google.com> <87zfzr2ejj.fsf@localhost> <18ba5e231e3.f989cde147196.3154436412643995109@excalamus.com> <875y2e2b9y.fsf@localhost> <18bb07473e2.1007b1565819307.6938164403009000496@excalamus.com> <877cmr2ke4.fsf@localhost> <18bb5337346.dfcd5ebb1139895.801408740607633332@excalamus.com> <18bd3d38ff3.115b786cb2560022.7704006411630399228@excalamus.com> <87fs169h7f.fsf@localhost> <18bd984270d.1048050a22954105.2819987720224062869@excalamus.com> <25942.29051.701153.391260@gargle.gargle.HOWL> <18bd9ea2f7b.b77346232985684.5614027527324280790@excalamus.com> <871qcod9ad.fsf@localhost> <25943.14504.245343.443507@gargle.gargle.HOWL> <87sf54bs61.fsf@localhost> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit User-Agent: Mozilla Thunderbird Content-Language: en-US, ru-RU In-Reply-To: Received-SPF: pass client-ip=116.202.254.214; envelope-from=geo-emacs-orgmode@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: 26 X-Spam_score: 2.6 X-Spam_bar: ++ X-Spam_report: (2.6 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FORGED_MUA_MOZILLA=2.309, FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, NML_ADSP_CUSTOM_MED=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -2.76 X-Spam-Score: -2.76 X-Migadu-Queue-Id: 5E64573346 X-Migadu-Scanner: mx11.migadu.com X-TUID: NE8cDvtzfyPK On 18/11/2023 15:04, Max Nikulin wrote: > On 17/11/2023 17:17, Ihor Radchenko wrote: > > I see bash vs. dash difference with public key authorization, so no need > for password prompts. I have not figured out how to construct an example > without ssh since this command *may* read stdin, but does not do it in a > same way as e.g. cat(1). I expect the following couple of lines simulates ssh behavior fairly well (besides maybe macOS with its old GPLv2 bash). bash -c 'read -t 0.5 -r line; printf "read: %s\n" "$line"' printf 'printf\n' > cat ssh-script.sh > ssh -p 2222 127.0.0.1 'echo foo>/tmp/foo' > echo done [...] > dash done > > bash # no output > > I have not expected this difference. [...] > I am unsure if POSIX specifies exact behavior of shell when commands are > read from stdin. It is a bug in dash that should be fixed in next version. Behavior of bash is correct despite some users may expect "done" printed. наб to dash@vger.kernel.org [PATCH] input: preadfd: read standard input byte-wise Tue, 13 Dec 2022 23:17:32 +0100 "dash: Incorrectly slurps script from stdin (POSIX compliance issue)" And curiously ssh command was involved as well "Debugging a mystery: ssh causing strange exit codes?" A citation from POSIX (XCU): STDIN in /sh - shell, the standard command language interpreter/ > When the shell is using standard input and it invokes a command that > also uses standard input, the shell shall ensure that the standard > input file pointer points directly after the command it has read when > the command begins execution. It shall not read ahead in such a manner > that any characters intended to be read by the invoked command are > consumed by the shell (whether interpreted by the shell or not) or > that characters that are not read by the invoked command are not seen > by the shell. When the command expecting to read standard input is > started asynchronously by an interactive shell, it is unspecified > whether characters are read by the command or interpreted by the > shell. I do not think any script should rely on this behavior, it is better to explicitly use "here documents" cat < "I'm reading a file line by line and running ssh or ffmpeg, only the first line gets processed!" So either "ssh -n" or "ssh is a different case unrelated to script files.