[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bash source code block: problem after ssh commands
From: |
Ihor Radchenko |
Subject: |
Re: bash source code block: problem after ssh commands |
Date: |
Mon, 06 Nov 2023 13:32:16 +0000 |
Bruno Barbier <brubar.cs@gmail.com> writes:
> IIUC, the elisp expression:
>
> (process-file "bash" "/tmp/test.sh")
>
> is more equivalent to:
>
> cat /tmp/test.sh | bash
>
> i.e. the shell is getting the commands from stdin. Thus, any command
> that uses stdin might change what gets executed or not.
Looking at `org-babel-sh-evaluate', it should be enough to specify
:shebang, :cmdline, or :stdin header argument to force using script
rather than channel source block as input to bash:
#+begin_src shell :results output :cmdline bash
exec 0>&-
echo OK
#+end_src
#+RESULTS:
: OK
#+begin_src shell :results output :cmdline bash
echo 1
read -p "Next command? " NEXT_COMMAND
echo 2
echo 3
#+end_src
#+RESULTS:
: 1
: 2
: 3
I am wondering about the possible downsides of using script approach
instead of stdin redirection.
--
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>
- Re: bash source code block: problem after ssh commands,
Ihor Radchenko <=
- Re: bash source code block: problem after ssh commands, Matt, 2023/11/06
- Re: bash source code block: problem after ssh commands, Ihor Radchenko, 2023/11/07
- Re: bash source code block: problem after ssh commands, Matt, 2023/11/08
- Re: bash source code block: problem after ssh commands, Ihor Radchenko, 2023/11/09
- Re: bash source code block: problem after ssh commands, Matt, 2023/11/09
- Re: bash source code block: problem after ssh commands, Matt, 2023/11/15
- Re: bash source code block: problem after ssh commands, Matt, 2023/11/15
- Re: bash source code block: problem after ssh commands, Ihor Radchenko, 2023/11/16
- Re: bash source code block: problem after ssh commands, Matt, 2023/11/16
- Re: bash source code block: problem after ssh commands, Alain . Cochard, 2023/11/16