* Blank first line in a tangled file prevents src block execution
@ 2012-03-09 21:57 Leo Alekseyev
2012-03-09 22:08 ` Nick Dokos
0 siblings, 1 reply; 5+ messages in thread
From: Leo Alekseyev @ 2012-03-09 21:57 UTC (permalink / raw)
To: Emacs orgmode
I have the following source block that I tangle to produce a short script:
#+begin_src sh :tangle code/get_wavs.sh
#!/bin/bash
for fn_in in "$@"; do
fn_out=$(sed -e 's|\.3gp$||g' -e 's|$|.wav|g' <<< $fn_in)
ffmpeg -i $fn_in -vn -f wav -acodec pcm_u8 $fn_out
done
#+end_src
However, the tangled file has a blank first line. As a result, I
can't seem to run this script either using sh -c, or by putting it
inside a code block. In other words, the following line fails:
sh -c "code/test.sh data/salsa/20120308_av_jc/song2/*.3gp"
code/test.sh: 4: Syntax error: redirection unexpected
And, similarly, this fails
#+begin_src sh
code/get_wavs.sh data/salsa/20120308_av_jc/song2/*.3gp
#+end_src
On the other hand, the script runs fine from the command line, or from
an org-mode shell: link, i.e. just running
code/test.sh data/salsa/20120308_av_jc/song2/*.3gp
at bash prompt produces the desired result.
I am not sure what the rules are about blank lines before the
hash-bang directive in Bash, and why in particular the blank line
seems to cause sh -c ... and orb-babel src execution to break, but the
current behavior seems broken.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Blank first line in a tangled file prevents src block execution
2012-03-09 21:57 Blank first line in a tangled file prevents src block execution Leo Alekseyev
@ 2012-03-09 22:08 ` Nick Dokos
2012-03-09 22:26 ` Eric Schulte
0 siblings, 1 reply; 5+ messages in thread
From: Nick Dokos @ 2012-03-09 22:08 UTC (permalink / raw)
To: Leo Alekseyev; +Cc: nicholas.dokos, Emacs orgmode
Leo Alekseyev <dnquark@gmail.com> wrote:
> I have the following source block that I tangle to produce a short script:
>
> #+begin_src sh :tangle code/get_wavs.sh
> #!/bin/bash
> for fn_in in "$@"; do
> fn_out=$(sed -e 's|\.3gp$||g' -e 's|$|.wav|g' <<< $fn_in)
> ffmpeg -i $fn_in -vn -f wav -acodec pcm_u8 $fn_out
> done
> #+end_src
>
> However, the tangled file has a blank first line. As a result, I
> can't seem to run this script either using sh -c, or by putting it
> inside a code block. In other words, the following line fails:
>
Add ":padline no"
Nick
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Blank first line in a tangled file prevents src block execution
2012-03-09 22:08 ` Nick Dokos
@ 2012-03-09 22:26 ` Eric Schulte
2012-03-09 23:14 ` Nick Dokos
0 siblings, 1 reply; 5+ messages in thread
From: Eric Schulte @ 2012-03-09 22:26 UTC (permalink / raw)
To: nicholas.dokos; +Cc: Emacs orgmode
Nick Dokos <nicholas.dokos@hp.com> writes:
> Leo Alekseyev <dnquark@gmail.com> wrote:
>
>> I have the following source block that I tangle to produce a short script:
>>
>> #+begin_src sh :tangle code/get_wavs.sh
>> #!/bin/bash
>> for fn_in in "$@"; do
>> fn_out=$(sed -e 's|\.3gp$||g' -e 's|$|.wav|g' <<< $fn_in)
>> ffmpeg -i $fn_in -vn -f wav -acodec pcm_u8 $fn_out
>> done
>> #+end_src
>>
>> However, the tangled file has a blank first line. As a result, I
>> can't seem to run this script either using sh -c, or by putting it
>> inside a code block. In other words, the following line fails:
>>
>
> Add ":padline no"
>
Or try
#+begin_src sh :tangle code/get_wavs.sh :shebang #!/bin/bash
for fn_in in "$@"; do
fn_out=$(sed -e 's|\.3gp$||g' -e 's|$|.wav|g' <<< $fn_in)
ffmpeg -i $fn_in -vn -f wav -acodec pcm_u8 $fn_out
done
#+end_src
--
Eric Schulte
http://cs.unm.edu/~eschulte/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Blank first line in a tangled file prevents src block execution
2012-03-09 22:26 ` Eric Schulte
@ 2012-03-09 23:14 ` Nick Dokos
2012-03-12 4:40 ` Eric Schulte
0 siblings, 1 reply; 5+ messages in thread
From: Nick Dokos @ 2012-03-09 23:14 UTC (permalink / raw)
To: Eric Schulte; +Cc: nicholas.dokos, Emacs orgmode
Eric Schulte <eric.schulte@gmx.com> wrote:
> Or try
>
> #+begin_src sh :tangle code/get_wavs.sh :shebang #!/bin/bash
> for fn_in in "$@"; do
> fn_out=$(sed -e 's|\.3gp$||g' -e 's|$|.wav|g' <<< $fn_in)
> ffmpeg -i $fn_in -vn -f wav -acodec pcm_u8 $fn_out
> done
> #+end_src
>
That reminds me: I believe shebang is used in tangling, but not in evaluation.
Assuming that's correct, is there any fundamental reason for it not being used
in evaluation?
Panruo Wu's question in another thread ( http://thread.gmane.org/gmane.emacs.orgmode/53157 )
brought this to mind.
Thanks,
Nick
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Blank first line in a tangled file prevents src block execution
2012-03-09 23:14 ` Nick Dokos
@ 2012-03-12 4:40 ` Eric Schulte
0 siblings, 0 replies; 5+ messages in thread
From: Eric Schulte @ 2012-03-12 4:40 UTC (permalink / raw)
To: nicholas.dokos; +Cc: Emacs orgmode
Nick Dokos <nicholas.dokos@hp.com> writes:
> Eric Schulte <eric.schulte@gmx.com> wrote:
>
>> Or try
>>
>> #+begin_src sh :tangle code/get_wavs.sh :shebang #!/bin/bash
>> for fn_in in "$@"; do
>> fn_out=$(sed -e 's|\.3gp$||g' -e 's|$|.wav|g' <<< $fn_in)
>> ffmpeg -i $fn_in -vn -f wav -acodec pcm_u8 $fn_out
>> done
>> #+end_src
>>
>
> That reminds me: I believe shebang is used in tangling, but not in evaluation.
> Assuming that's correct, is there any fundamental reason for it not being used
> in evaluation?
>
Shell code blocks are evaluated using the org-babel-sh-command variable.
When the executing command is explicitly provided there is no need for a
shebang line, and it would be (to my knowledge) ignored.
Best,
--
Eric Schulte
http://cs.unm.edu/~eschulte/
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-03-12 16:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-09 21:57 Blank first line in a tangled file prevents src block execution Leo Alekseyev
2012-03-09 22:08 ` Nick Dokos
2012-03-09 22:26 ` Eric Schulte
2012-03-09 23:14 ` Nick Dokos
2012-03-12 4:40 ` Eric Schulte
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).