all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Sébastien Vauban" <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org>
To: emacs-orgmode-mXXj517/zsQ@public.gmane.org
Subject: [Babel] Debugging shell code that misbehaves
Date: Thu, 14 Oct 2010 14:56:00 +0200	[thread overview]
Message-ID: <80zkuhkk67.fsf@mundaneum.com> (raw)

#+TITLE:     Debugging shell code that misbehaves
#+DATE:      2010-10-14
#+LANGUAGE:  en_US

* Use case

Let's say that:

- This file is in =~/Client/Spec=
- I'm working on such a chunk of code:

#+begin_src sh :results output :exports results
grep indAllocType ../Ontology/champs.csv |\
iconv -f LATIN1 -t UTF8 |\
tr "[]" "|" | cut -d "|" -f 2 | cut -d " " -f 2- |\
sed 's%, %\n%g'
#+end_src

and that, when executing it, I've got an error with not enough context for me
to understand what's the problem is.

Sneak preview: under Cygwin, the =to= language (of the =iconv= command) must
be =UTF-8= in the above case (with a dash).

* Debug it

So, in order to debug, I decide to add a =session= argument:

#+begin_src sh :results output :exports results :session sva
grep indAllocType ../Ontology/champs.csv |\
iconv -f LATIN1 -t UTF8 |\
tr "[]" "|" | cut -d "|" -f 2 | cut -d " " -f 2- |\
sed 's%, %\n%g'
#+end_src

and, there, something totally different is occurring: =grep= is not finding
the file anymore.

Why? Because adding the session argument makes the code executed from my *home
directory*, while it was executed from the *document's directory* in the first
place.

So, this is not the right way to debug... as *conditions do change*.

* Solution?

What's the right solution for such a case?

- Putting a full path to the file =champs.csv= (instead of the relative one)
  is not OK for me, as all of this is under SVN, and I want this to be
  executable on someone's else PC (even if placed somewhere else).

- Add an explicit =cd= to the right place, before the commands execute. Not
  possible, for the same reason as above.

Is there some natural way to work around this?

Best regards,
  Seb

-- 
Sébastien Vauban


_______________________________________________
Emacs-orgmode mailing list
Please use `Reply All' to send replies to the list.
Emacs-orgmode-mXXj517/zsQ@public.gmane.org
http://lists.gnu.org/mailman/listinfo/emacs-orgmode

             reply	other threads:[~2010-10-14 12:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-14 12:56 Sébastien Vauban [this message]
2010-10-14 13:18 ` [Babel] Debugging shell code that misbehaves Dan Davison
2010-10-18 21:38   ` Sébastien Vauban
2010-10-19 10:18     ` Dan Davison

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=80zkuhkk67.fsf@mundaneum.com \
    --to=wxhgmqzgwmuf-genee64ty+gs+fvcfc7uqw@public.gmane.org \
    --cc=emacs-orgmode-mXXj517/zsQ@public.gmane.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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.