From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id cOgIJrBzWGUjYwEA9RJhRA:P1 (envelope-from ) for ; Sat, 18 Nov 2023 09:20:00 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id cOgIJrBzWGUjYwEA9RJhRA (envelope-from ) for ; Sat, 18 Nov 2023 09:20:00 +0100 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 6105253E43 for ; Sat, 18 Nov 2023 09:20:00 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Pn2VroEw; 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"; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1700295600; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=x3Ldvs4qnBQxWQkpHhdMGynBVFnSPsf+muZOCXPl5j0=; b=MevpNRh1iVbXv0zGmUCMn8qH54tF3SJ/CdEhN0qviTZdO5Jq3wXjL53Iy2LQTptZoiiCY/ 4d4cZ+zIaGs9UI/lK9X+tWixf7ko60THo9ruggssVmpkvtzYlPunrT52osykO4aVOptCyJ WtfTFBrqZJwsE4npBcPMotsKe/IqXVoSxtrxdxSgkIbnZViRA+APFSTJVYYoCARMRo3kxe ySZI/T/wN5wxekt+LWcMP0eBowMPCzFdeyAigJx0LEXZ7AyHCpHW4Xxm7aNHfpGor+/kTf UOe0OItAr/B+0M6Gun5EmpU0B3LOIWfRouEOAKGdF0AdK5Lx7Msor0OtnUVHOg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Pn2VroEw; 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"; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=key1; d=yhetil.org; t=1700295600; a=rsa-sha256; cv=none; b=M2hkxwCUn5JFlJwtl3zGNaT32/ykE3gbFMyjc4WGzAhaaZTFXXW6FGWJRY75J3bDQYJ8bN w++0hTottvbte92W7X/xvSugsgt+FvhWXH2L+MuP4xK/53zg1A8d8FOsmyFhyWNo3uMVZU d+AM3OCOYUz8jHDwC8uZHJx+gDeEEvAR4lawfhlk99+aM+eLSo3CHTU41e0Ca8r87rfAw5 sZQTP2A9ysP3VKE4cwDj6a2b6Jy4rg9X8llcfw6j+nuP4LJxdqQ0WnD6s9m2e315zkpXYV PXdyBCI/i7ELODQ3RaKtdhp76m2VUDFR6LiFpUiVkElnugkOtO4fZu95PDeU5g== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r4GY1-0006w3-Hs; Sat, 18 Nov 2023 03:19:25 -0500 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 1r4GXv-0006vd-7A for emacs-orgmode@gnu.org; Sat, 18 Nov 2023 03:19:20 -0500 Received: from mail-wr1-x431.google.com ([2a00:1450:4864:20::431]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r4GXt-0006Qe-ES for emacs-orgmode@gnu.org; Sat, 18 Nov 2023 03:19:18 -0500 Received: by mail-wr1-x431.google.com with SMTP id ffacd0b85a97d-32fdc5be26dso1783837f8f.2 for ; Sat, 18 Nov 2023 00:19:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700295556; x=1700900356; darn=gnu.org; h=mime-version:date:references:in-reply-to:subject:cc:to:from :message-id:from:to:cc:subject:date:message-id:reply-to; bh=x3Ldvs4qnBQxWQkpHhdMGynBVFnSPsf+muZOCXPl5j0=; b=Pn2VroEwjRtXfC+Atc8EwY+yejEneTr9/7MGVLcf2UDwJPPR3jHeToNJ5AM1Yobx0v WwDXRWOWHJTg0eeNuiilhF+goIx8OiIwgCf+gLkhOAEeEQOlYwzDb0nDN2Yf91DNByUM J8RncNqGS0yySBlBqA7xuOwjWg6m6puz8BMM9ewnSbeO00LjP1YH0Hb05ffgTo9L6d27 jOJtrMMntl31ngjKQQJQmxznq/GM825/Xhv79KLfe4Wf23rNC6eXdExe2pFr/oilWIRR x2vc0bvPi2urEmvGQGgOCZTqhX+MTdXJOKHwXLlvss4rK/BvAlGyQ8PNkbEUkxT3RUvs QYTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700295556; x=1700900356; h=mime-version:date:references:in-reply-to:subject:cc:to:from :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=x3Ldvs4qnBQxWQkpHhdMGynBVFnSPsf+muZOCXPl5j0=; b=sT0cXTmpvrvu5IEwvbSghcysnbACx+CgU5fx0It6xdSaT9lRa29zw2WCsY/YkPRSlZ iHPaaszP9xHjSQdpRgPT++7rp8jt/MYbteztL8+nQ4bal8UnFziIzYOSNIH0h5d95Abu fuAg9ZveNO7rD6mrxD/7YvyS+ukULLcKJFCVF7KgbeF10EdoScd1kUzQV/DrVMmVVgVY CYmHdnM/cZ9Our3qRJQp0yC7vImND7Hc6l0fkFbX4i8B9yu/jc8oZ9Vm3z6OH3/DWlFG ivnEX2j7U8yGqbKm5aaNYLeg8Q/PG5NqDxTwTN54lWg4aPwKQmhTGwu4THEIdLts9IAo ro1A== X-Gm-Message-State: AOJu0YxwCbbQfByFG7RJa7QmgEQSXgQ5TByWpvkGwIa1lglcz1SHLKB3 hh/wBRStATU2P5R8rY8RSRs= X-Google-Smtp-Source: AGHT+IH0u2MY/ZiNWA5cj4+YRjiRSF++CA4rzmLd4N03ee2yb3VpTCNRFfu8iGMJDyIiABGIIY/BHA== X-Received: by 2002:a05:6000:4028:b0:331:5975:a862 with SMTP id cp40-20020a056000402800b003315975a862mr1441041wrb.3.1700295555641; Sat, 18 Nov 2023 00:19:15 -0800 (PST) Received: from keynux ([2a01:e0a:505:3460:1c18:688d:ece4:372e]) by smtp.gmail.com with ESMTPSA id o2-20020a5d4a82000000b003196b1bb528sm4674160wrq.64.2023.11.18.00.19.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Nov 2023 00:19:15 -0800 (PST) Message-ID: <65587383.5d0a0220.27bea.0b92@mx.google.com> Received: by keynux (sSMTP sendmail emulation); Sat, 18 Nov 2023 09:19:13 +0100 From: Bruno Barbier To: Matt , Ihor Radchenko Cc: "emacs-orgmode@gnu.org" Subject: Re: bash source code block: problem after ssh commands In-Reply-To: <18bdf538f2f.126bad4763316098.8581777358227217138@excalamus.com> 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> <18bdf538f2f.126bad4763316098.8581777358227217138@excalamus.com> Date: Sat, 18 Nov 2023 09:19:13 +0100 MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=2a00:1450:4864:20::431; envelope-from=brubar.cs@gmail.com; helo=mail-wr1-x431.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, MSGID_FROM_MTA_HEADER=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham 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: -9.40 X-Spam-Score: -9.40 X-Migadu-Queue-Id: 6105253E43 X-Migadu-Scanner: mx13.migadu.com X-TUID: Zpc5t0IkrPHM Hi Matt, Thanks this summary and for working on this! Just a few comments/corrections about some specific points, hoping it might help. Matt writes: > ---- On Fri, 17 Nov 2023 10:20:28 +0100 Ihor Radchenko wrote --- > > > This has nothing to do with Emacs comint and this is also not a bug in > > Emacs > > Ihor, there were two claims made in the original report. I was referring to Claim 2. That deals with M-x shell and therefore comint-mode. > > Regarding Claim 1: > > - Can anyone verify Claim 1? I do: the file is created and the command "echo bar" is NOT executed. Here is my code block and its results: #+begin_src bash :results output ssh phone "echo foo>foo_file" echo "bar" #+end_src #+RESULTS: No results (the echo command is NOT executed). The file "foo_file" is created on the remote; its content is "foo". #+begin_src bash :results output date ssh -n phone "ls -alh foo_file" ssh -n phone "cat foo_file" #+end_src #+RESULTS: : Sat Nov 18 08:33:59 CET 2023 : -rw------- 1 u0_a256 u0_a256 4 Nov 18 08:26 foo_file : foo > - What versions are people using? > + M-x org-version > + M-x emacs-version #+begin_src elisp (list emacs-version org-version) #+end_src #+RESULTS: | 30.0.50 | 9.7-pre | GNU/Linux gentoo > ... > * Comments about the claims: > ** Comment 1. > ... > I am unable to reproduce the reported behavior (of > "bar" not returning). Instead, I get an ssh-askpass permission denied > error, foo_file is not created, and "bar" is given as the result. I > do not see anywhere in the thread that the original claim was > reproduced. It seems your SSH failed to connect. In that case, I cannot swallow the second command; thus the command "echo bar" is executed. I can reproduce what you see on my side if I force the connection to fail: #+begin_src bash :results output ssh WRONG_REMOTE "echo foo>foo_file" echo "bar" #+end_src #+RESULTS: : bar > > The thread preceded something like follows. > > Leo Butler suggested two work arounds: > > - add the -f to the ssh command > - add a semi-colon and line continuation to the first line. > > Russell Adams suggested another work around: > > - add -n to the ssh command That's the one I use; the option -n is enough for me ('-n' = Redirects stdin from /dev/null). The option '-f' means SSH will go to background; I'm not sure I want that. > ... > ... > He then proposes an experiment to close stdin. To do this, he calls > > #+begin_src shell :results output > exec 0>&- > echo OK > #+end_src > > He claims that "exec 0<&-" closes stdin. I believe there is a typo. > ... You're right. Good catch, thanks! Although it seems to work either way on my side. #+begin_src shell :results output exec 0<&- echo OK #+end_src #+RESULTS: #+begin_src shell :results output exec 0>&- echo OK #+end_src #+RESULTS: > What Bruno writes corresponds to "closing output file descriptor 0". I honestly don't know what the difference is between an "output file descriptor" and an "input file descriptor". I had no luck finding this information in man bash or info bash. > My point was: the commands are read the standard input, thus, any command that modifies that standard input will modify what gets executed. > ... > This is what we see in Org. I'll be honest, though, I don't > really know what to expect with exec 0>&- and exec 0<&-. When I call > them in the terminal, it kills the terminal. Let's forget about 'exec 0<&-' (closing the standard input/outputs): this is bringing other corner cases. But, yes, I would expect a terminal to close itself automatically if its input is closed. > ... > As far as I can tell, though, that's not what prevents "bar" from being returned. As far as I can reproduce, calling > > #+begin_src bash :results output > ssh localhost "echo foo>foo_file" > echo "bar" > #+end_src > > *does* give "bar" for results even though it shouldn't. Does it echo bar when the SSH connection succeeds too ? Thanks again for working on this. Bruno