emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Bruno Barbier <brubar.cs@gmail.com>
To: Ihor Radchenko <yantar92@posteo.net>, Alain.Cochard@unistra.fr
Cc: Matt <matt@excalamus.com>,
	"emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: bash source code block: problem after ssh commands
Date: Fri, 17 Nov 2023 16:47:51 +0100	[thread overview]
Message-ID: <65578b29.050a0220.8941c.b420@mx.google.com> (raw)
In-Reply-To: <87sf54bs61.fsf@localhost>


Hi Matt, Ihor, Alain,

Ihor Radchenko <yantar92@posteo.net> writes:

> Alain.Cochard@unistra.fr writes:
>
>> At the most basic user level (i.e., non lisp aware), why is it not
>> necessarily a bug if "something" does the expected in an X terminal
>> but not in an emacs terminal?  I think Matt and I (and others) are on
>> the same page here, and he already essentially drafted the bug report
>> I would have sent (only better).
>
> WRT M-x shell, feel free to submit a bug report. I mostly pointed that
> the problem with M-x shell is not the problem you originally ran to. It
> is a different problem (also, we ran into it in the past).

FWIW, M-x shell differs from what a plain terminal is doing (xterm, in
my case), but, I do prefer 'M-x shell' behavior: it allows me to copy
multiple lines, getting the same results as when I type them manually,
or copy them line by line. My xterm doesn't seem to allow me to do that.


>> What also confuses me is that it seems to me that, in the minimum
>> working example, you consider the ssh command and the read command as
>> equivalent.  But I don't even enter the password when using ssh...

I've introduced the 'read' example, as a simpler way to modify the
standard input and get the same kind of "unexpected" results, without
relying on SSH.  It seems that I have only caused confusion, sorry about
that.

IIUC, the OP example is not working because SSH is modifying the
standard input (with or without passwords).

> I was only able to reproduce your problem with ssh asking a password.
> We are discussing the reproduced case.
>
> If you see problems with
>    #+begin_src bash :results output
>    ssh cochard@fruc.u-strasbg.fr "echo foo>foo_file"
>    echo "bar"
>    #+end_src
>
> even when ssh does not ask for a password, please provide more detailed
> reproducer that we can replicate locally without guessing your ssh config.
>

I'm not the OP, but, my SSH is configured to work without passwords and
SSH is still consuming lines from standard input:

    #+begin_src bash :results output
    ssh phone echo "remote"
    echo "local"
    #+end_src

    #+RESULTS:
    : remote

It looks like it is a known SSH "feature" (see
https://unix.stackexchange.com/a/688024):

    #+begin_src bash :results output
    seq 1000000 | (ssh phone sleep 1; wc -l)
    #+end_src

    #+RESULTS:
    : 675173

Same block, but asking SSH to not use stdin (using '-n' as mentionned in
this thread):

    #+begin_src bash :results output
    seq 1000000 | (ssh -n phone sleep 1; wc -l)
    #+end_src

    #+RESULTS:
    : 1000000

IMHO, what ob-shell is doing today seems a valid way of evaluating
source blocks (and it seems to have been like that for a long time).  It
should probably be documented somewhere, so that users know how to write
their source blocks, or switch to another way, like adding a :cmdline
parameter as mentionned in this thread.


Hoping I didn't increase the confusion again,
:-)


Bruno




> -- 
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at <https://orgmode.org/>.
> Support Org development at <https://liberapay.com/org-mode>,
> or support my work at <https://liberapay.com/yantar92>


  parent reply	other threads:[~2023-11-17 15:49 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-25 11:17 bash source code block: problem after ssh commands Alain.Cochard
2023-10-25 15:12 ` Leo Butler
2023-10-25 16:14   ` Alain.Cochard
2023-10-25 16:47     ` Leo Butler
2023-10-25 16:59     ` yaxp
2023-10-26  8:44   ` Ihor Radchenko
2023-10-26 13:23     ` Alain.Cochard
2023-10-26 13:44       ` Ihor Radchenko
2023-10-27 18:26         ` Alain.Cochard
2023-10-28  5:22           ` Max Nikulin
2023-10-30 10:50           ` Bruno Barbier
2023-11-06 13:32             ` Ihor Radchenko
2023-11-06 18:25               ` Matt
2023-11-07  8:55                 ` Ihor Radchenko
2023-11-08 19:41                   ` Matt
2023-11-09 12:14                     ` Ihor Radchenko
2023-11-09 17:48                       ` Matt
2023-11-15 16:32                         ` Matt
2023-11-15 18:04                           ` Matt
2023-11-16  9:32                           ` Ihor Radchenko
2023-11-16 19:03                             ` Matt
2023-11-16 19:46                               ` Alain.Cochard
2023-11-16 20:54                                 ` Matt
2023-11-17  9:22                                   ` Ihor Radchenko
2023-11-17  9:55                                     ` Alain.Cochard
2023-11-17 10:17                                       ` Ihor Radchenko
2023-11-17 15:32                                         ` Leo Butler
2023-11-17 15:47                                         ` Bruno Barbier [this message]
2023-11-18 10:37                                           ` Ihor Radchenko
2023-11-21 19:01                                             ` Bruno Barbier
2023-11-22 17:06                                               ` Max Nikulin
2023-11-19  4:17                                           ` Non-emacs shell (Re: bash source code block: problem after ssh commands) Max Nikulin
2023-11-21 15:33                                             ` Bruno Barbier
2023-11-18  8:04                                         ` bash source code block: problem after ssh commands Max Nikulin
2023-11-18 10:43                                           ` Ihor Radchenko
2023-11-18 16:18                                             ` Max Nikulin
2023-11-17 22:07                                     ` Matt
2023-11-18  3:11                                       ` Forget about "bash -c bash file.sh" (Re: bash source code block: problem after ssh commands) Max Nikulin
2023-11-18  8:11                                         ` Matt
2023-11-18  8:29                                           ` Bruno Barbier
2023-11-18  8:43                                             ` Matt
2023-11-18  8:54                                               ` Bruno Barbier
2023-11-18  9:09                                                 ` Matt
2023-11-18  9:11                                                   ` Bruno Barbier
2023-11-18 10:47                                                   ` Ihor Radchenko
2023-11-18  8:19                                       ` bash source code block: problem after ssh commands Bruno Barbier
2023-11-18  9:02                                         ` Matt
2023-11-18 15:51                                       ` Matt
2023-10-26 14:44 ` Russell Adams
2023-10-27 11:47   ` Alain.Cochard
2023-11-06 18:01     ` Matt
2023-11-07  0:51       ` Alain.Cochard
2023-11-18  8:09 ` Max Nikulin
2023-11-18  8:36   ` Bruno Barbier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=65578b29.050a0220.8941c.b420@mx.google.com \
    --to=brubar.cs@gmail.com \
    --cc=Alain.Cochard@unistra.fr \
    --cc=emacs-orgmode@gnu.org \
    --cc=matt@excalamus.com \
    --cc=yantar92@posteo.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).