[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [BUG] ob-shell: :shebang changes interpretation of :cmdline
From: |
Matt |
Subject: |
Re: [BUG] ob-shell: :shebang changes interpretation of :cmdline |
Date: |
Mon, 04 Dec 2023 21:41:18 +0100 |
User-agent: |
Zoho Mail |
---- On Mon, 04 Dec 2023 14:55:58 +0100 Ihor Radchenko wrote ---
> Matt matt@excalamus.com> writes:
>
> > > #+begin_src bash :cmdline 1 2 3
> > > printf "%s\n" "$1"
> > > #+end_src
> > >
> > > #+RESULTS:
> > > : 1
> > >
> > > #+begin_src bash :cmdline 1 2 3 :shebang #!/bin/bash
> > > printf "%s\n" "$1"
> > > #+end_src
> > >
> > > #+RESULTS:
> > > : 1 2 3
> >
> > Thank you! This makes a good test case.
>
> I am confused. Isn't it a bug?
Yes, it's a bug. And the test was wrong.
Here is a corrected version. When the bug is fixed, the following should pass.
It currently fails because the first block returns 1 and the second block
returns 1 2 3 (as seen in the quote). Both blocks should return 1.
(ert-deftest test-cmdline-alone-and-with-shebang-have-same-result ()
"Pass arguments to a block. Don't use shebang. Then use
shebang set to the same language as the block. The result should
be the same."
(should (equal
(org-test-with-temp-text
"#+begin_src bash :cmdline 1 2 3
echo \"$1\"
<point>
#+end_src"
(org-babel-execute-src-block))
(org-test-with-temp-text
"#+begin_src bash :cmdline 1 2 3 :shebang #!/bin/bash
echo \"$1\"
<point>
#+end_src"
(org-babel-execute-src-block)))))