From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?utf-8?Q?S=C3=A9bastien_Vauban?= Subject: [Babel] Debugging shell code that misbehaves Date: Thu, 14 Oct 2010 14:56:00 +0200 Message-ID: <80zkuhkk67.fsf@mundaneum.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org-mXXj517/zsQ@public.gmane.org To: emacs-orgmode-mXXj517/zsQ@public.gmane.org #+TITLE: Debugging shell code that misbehaves #+DATE: 2010-10-14 #+LANGUAGE: en_US * Use case Let's say that: - This file is in =3D~/Client/Spec=3D - 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 =3Dto=3D language (of the =3Diconv=3D comm= and) must be =3DUTF-8=3D in the above case (with a dash). * Debug it So, in order to debug, I decide to add a =3Dsession=3D 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: =3Dgrep=3D is not fin= ding the file anymore. Why? Because adding the session argument makes the code executed from my *h= ome directory*, while it was executed from the *document's directory* in the fi= rst 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 =3Dchamps.csv=3D (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 =3Dcd=3D 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 --=20 S=C3=A9bastien 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