emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: "Eric Schulte" <schulte.eric@gmail.com>
To: Achim Gratz <Stromeko@nexgo.de>
Cc: emacs-orgmode@gnu.org
Subject: Re: Re: [babel] Sh problem when echo'ing input data with ' inside
Date: Mon, 17 Jan 2011 13:29:15 -0700	[thread overview]
Message-ID: <87y66ji89w.fsf@gmail.com> (raw)
In-Reply-To: <87k4i3uwpm.fsf@Rainer.invalid> (Achim Gratz's message of "Mon, 17 Jan 2011 21:00:37 +0100")

Achim Gratz <Stromeko@nexgo.de> writes:

> Sébastien Vauban <wxhgmqzgwmuf@spammotel.com>
> writes:
>> However, I can't do any work on the input file, the very basic echo command
>> already giving an error:
>
> This is because quoting the arguments to echo does not work when your
> input contains unescaped quote characters.  I've no idea how exactly
> babel tries to get it's arguments to the command, but it looks like it
> simply copies text and executes the resulting script?  If it could open
> a pipe and send the data through, no quoting would be necessary since
> the shell never sees the data.  I'm not sure if that's possible because
> I can't find specific documentation on language "sh".
>
> [Note: orgmode online manual links to
>  http://orgmode.org/worg/org-contrib/babel/languages/ which is broken.]
>

yes, the Worg documentation is in dire need of maintenance, see below
for discussion of how arguments are passed in the sh blocks

>
>> #+begin_src sh :var data=excel-from-bank :results output
>> echo "$data"
>> #+end_src
>
> So, you're using a un*xoid?  This is your lucky day, since in your case you
> should be able to use a here script:
>
> #+begin_src sh :var data=excel-from-bank :results output
> echo <<EOF | cmd1 | cmd2
> $data
> EOF
> #+end_src
>

here scripts are how Babel sends data through to a shell script, as far
as I know they should have no issues with quotes (or any other
character)

specifically, the following code block

    #+results: something
    #+begin_example
      something
      and something else
      with apostrophes ' and quotes "
      this should all work...
    #+end_example

    #+begin_src sh :var data=something
      echo $data
    #+end_src

Expands to

    #+begin_src sh
      data=$(cat <<BABEL_STRING
      something
        and something else
        with apostrophes ' and quotes "
        this should all work...
      BABEL_STRING
      )
      echo $data
    #+end_src

Cheers -- Eric

  reply	other threads:[~2011-01-17 20:29 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-17 12:42 [babel] Sh problem when echo'ing input data with ' inside Sébastien Vauban
2011-01-17 16:24 ` Eric Schulte
2011-01-17 19:29   ` Sébastien Vauban
2011-01-17 19:54     ` Eric Schulte
2011-01-17 22:49       ` Sébastien Vauban
2011-01-17 20:00 ` Achim Gratz
2011-01-17 20:29   ` Eric Schulte [this message]
2011-01-17 21:36   ` Achim Gratz
2011-01-17 22:39     ` Sébastien Vauban
2011-01-17 22:51       ` Achim Gratz
2011-01-18  7:02         ` Sébastien Vauban
2011-01-18  9:22       ` Sébastien Vauban
2011-01-18 16:24         ` Eric Schulte
2011-01-18 17:31           ` Sébastien Vauban
2011-01-18 18:23         ` Achim Gratz
2011-01-20 19:17         ` Achim Gratz
2011-01-20 22:12           ` Sébastien Vauban

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=87y66ji89w.fsf@gmail.com \
    --to=schulte.eric@gmail.com \
    --cc=Stromeko@nexgo.de \
    --cc=emacs-orgmode@gnu.org \
    /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).