From: Nick Dokos <nicholas.dokos@hp.com>
To: Eric Schulte <eric.schulte@gmx.com>
Cc: nicholas.dokos@hp.com, Tom Regner <tom@goochesa.de>,
emacs-orgmode@gnu.org, Panruo Wu <pwu@mymail.mines.edu>
Subject: Re: org babel execute shell in sh?
Date: Mon, 12 Mar 2012 15:10:58 -0400 [thread overview]
Message-ID: <4663.1331579458@alphaville> (raw)
In-Reply-To: Message from Eric Schulte <eric.schulte@gmx.com> of "Mon, 12 Mar 2012 13:29:02 EDT." <87aa3ld8yp.fsf@gmx.com>
Eric Schulte <eric.schulte@gmx.com> wrote:
> I just pushed up a patch which adds this behavior. It does result in
> some odd new possibilities, such as the following.
>
> #+begin_src sh :shebang #!/bin/cat
> foo
> #+end_src
>
> #+RESULTS:
> | #!/bin/cat |
> | |
> | foo |
>
Maybe my settings are slightly different, but the new bits give me
,----
| #+begin_src sh :shebang #!/bin/cat
| foo
| #+end_src
|
| #+RESULTS:
| : foo
`----
They also give me sensible results with the original example:
,----
| #+begin_src sh :shebang #!/bin/bash
| for np in {1..32}
| do
| echo $np
| done
| #+end_src
|
| #+RESULTS:
| | 1 |
| | 2 |
| | 3 |
| |... |
| | 31 |
| | 32 |
`----
The only potentially confusing case I've found is the following:
,----
| #+begin_src sh
| #!/bin/bash
| for np in {1..32}
| do
| echo $np
| done
| #+end_src
|
| #+RESULTS:
| : {1..32}
`----
with the shebang as part of the script. I'd argue it's doing the right
thing however: if one remembers that sh is the default command, this is
equivalent to the command line invocation:
,----
| $ sh foo.sh
`----
where foo.sh contains
--8<---------------cut here---------------start------------->8---
#!/bin/bash
for np in {1..32}
do
echo $np
done
--8<---------------cut here---------------end--------------->8---
and that too gives:
,----
| $ sh foo.sh
| {1..32}
`----
whereas
,----
| $ ./foo.sh
| 1
| 2
| 3
| ...
| 31
| 32
`----
In other words, sh does not interpret the shebang: that is only done
by the exec system call.
Nick
prev parent reply other threads:[~2012-03-12 19:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-07 17:25 org babel execute shell in sh? Panruo Wu
2012-03-08 0:22 ` Nick Dokos
2012-03-08 4:24 ` Tom Regner
2012-03-09 20:34 ` Panruo Wu
2012-03-10 4:21 ` Nick Dokos
2012-03-10 6:33 ` Tom Regner
2012-03-12 4:34 ` Eric Schulte
2012-03-12 16:38 ` Tom Regner
2012-03-12 17:29 ` Eric Schulte
2012-03-12 19:10 ` Nick Dokos [this message]
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=4663.1331579458@alphaville \
--to=nicholas.dokos@hp.com \
--cc=emacs-orgmode@gnu.org \
--cc=eric.schulte@gmx.com \
--cc=pwu@mymail.mines.edu \
--cc=tom@goochesa.de \
/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).