* [Babel] Debugging shell code that misbehaves
@ 2010-10-14 12:56 Sébastien Vauban
2010-10-14 13:18 ` Dan Davison
0 siblings, 1 reply; 4+ messages in thread
From: Sébastien Vauban @ 2010-10-14 12:56 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
#+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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Babel] Debugging shell code that misbehaves
2010-10-14 12:56 [Babel] Debugging shell code that misbehaves Sébastien Vauban
@ 2010-10-14 13:18 ` Dan Davison
2010-10-18 21:38 ` Sébastien Vauban
0 siblings, 1 reply; 4+ messages in thread
From: Dan Davison @ 2010-10-14 13:18 UTC (permalink / raw)
To: Sébastien Vauban; +Cc: public-emacs-orgmode-mXXj517/zsQ
Sébastien Vauban <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org>
writes:
> #+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.
Hi Seb,
This would be a bug. For me (ubuntu), the session does start up in the
document's directory. Perhaps the emacs shell session behaves
differently on your operating system (cygwin?)?
>
> So, this is not the right way to debug... as *conditions do change*.
but should not
>
> * Solution?
>
> What's the right solution for such a case?
Fix the bug. But failing that,
> - 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.
does it help to use a :dir header argument to specify default-directory
for the session?
Dan
>
> Is there some natural way to work around this?
>
> Best regards,
> Seb
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Babel] Debugging shell code that misbehaves
2010-10-14 13:18 ` Dan Davison
@ 2010-10-18 21:38 ` Sébastien Vauban
2010-10-19 10:18 ` Dan Davison
0 siblings, 1 reply; 4+ messages in thread
From: Sébastien Vauban @ 2010-10-18 21:38 UTC (permalink / raw)
To: emacs-orgmode-mXXj517/zsQ
Hi Dan,
Dan Davison wrote:
> Sébastien Vauban writes:
>
>> #+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.
>
> This would be a bug. For me (ubuntu), the session does start up in the
> document's directory. Perhaps the emacs shell session behaves differently on
> your operating system (cygwin?)?
How could we proove who's doing that effect? Do you have an idea for testing
this, and identifying what portion of code (be it Org, Babel or Cygwin) would
need to be fixed or customized?
>> So, this is not the right way to debug... as *conditions do change*.
>
> but should not
>
>>
>> * Solution?
>>
>> What's the right solution for such a case?
>
> Fix the bug. But failing that,
Good...
>> - 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.
>
> does it help to use a :dir header argument to specify default-directory
> for the session?
Such a dir spec does not seem to be respected:
#+begin_src sh :results output :exports results :session sva :dir /cygdrive/c/home/sva/Projects/Client
grep indAllocType ../Ontology/champs.csv |\
iconv -f LATIN1 -t UTF-8 |\
tr "[]" "|" | cut -d "|" -f 2 | cut -d " " -f 2- |\
sed 's%, %\n%g'
#+end_src
Doing pwd in the session buffer, and I see I'm still in ~ (/cygdrive/c/home/sva).
Moreover, no, that would not, as I cannot predict where the file will be
located on my colleagues' machines, except if I could add there a relative
spec such as ":dir ./".
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Babel] Debugging shell code that misbehaves
2010-10-18 21:38 ` Sébastien Vauban
@ 2010-10-19 10:18 ` Dan Davison
0 siblings, 0 replies; 4+ messages in thread
From: Dan Davison @ 2010-10-19 10:18 UTC (permalink / raw)
To: Sébastien Vauban; +Cc: public-emacs-orgmode-mXXj517/zsQ
Sébastien Vauban <wxhgmqzgwmuf-geNee64TY+gS+FvcfC7Uqw@public.gmane.org>
writes:
> Hi Dan,
>
> Dan Davison wrote:
>> Sébastien Vauban writes:
>>
>>> #+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.
>>
>> This would be a bug. For me (ubuntu), the session does start up in the
>> document's directory. Perhaps the emacs shell session behaves differently on
>> your operating system (cygwin?)?
>
> How could we proove who's doing that effect? Do you have an idea for testing
> this, and identifying what portion of code (be it Org, Babel or Cygwin) would
> need to be fixed or customized?
Hi Seb,
What happens if you do:
1. Kill all current *shell* sessions/buffers
2. Use M-x cd to change the emacs default-directory
3. Issue M-x shell
4. Query the current directory of the shell session with pwd
Dan
>
>
>>> So, this is not the right way to debug... as *conditions do change*.
>>
>> but should not
>>
>>>
>>> * Solution?
>>>
>>> What's the right solution for such a case?
>>
>> Fix the bug. But failing that,
>
> Good...
>
>
>>> - 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.
>>
>> does it help to use a :dir header argument to specify default-directory
>> for the session?
>
> Such a dir spec does not seem to be respected:
>
> #+begin_src sh :results output :exports results :session sva :dir /cygdrive/c/home/sva/Projects/Client
> grep indAllocType ../Ontology/champs.csv |\
> iconv -f LATIN1 -t UTF-8 |\
> tr "[]" "|" | cut -d "|" -f 2 | cut -d " " -f 2- |\
> sed 's%, %\n%g'
> #+end_src
>
> Doing pwd in the session buffer, and I see I'm still in ~ (/cygdrive/c/home/sva).
>
> Moreover, no, that would not, as I cannot predict where the file will be
> located on my colleagues' machines, except if I could add there a relative
> spec such as ":dir ./".
>
> Best regards,
> Seb
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-10-19 10:19 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-10-14 12:56 [Babel] Debugging shell code that misbehaves Sébastien Vauban
2010-10-14 13:18 ` Dan Davison
2010-10-18 21:38 ` Sébastien Vauban
2010-10-19 10:18 ` Dan Davison
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.