help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to avoid having shell scripts which fail from killing Emacs shel


From: Pascal J. Bourguignon
Subject: Re: How to avoid having shell scripts which fail from killing Emacs shell?
Date: Tue, 23 Jun 2009 10:54:32 +0200
User-agent: Gnus/5.101 (Gnus v5.10.10) Emacs/22.2 (gnu/linux)

David Karr <davidmichaelkarr@gmail.com> writes:

> On Jun 20, 2:06 am, Peter Dyballa <Peter_Dyba...@Web.DE> wrote:
>> Am 20.06.2009 um 01:03 schrieb David Karr:
>>
>> > to configure Emacs or the Bash inside Emacs, so that it doesn't get  
>> > killed when a script it's running fails.
>>
>> Make the shell script trap (shell built-in) this catastrophic error  
>> and just execute an exit (shell built-in) instead (in last millennium  
>> this was standard). You can also run shell scripts asynchronously in  
>> a dedicated temporary buffer by executing it as a shell or compile  
>> command.
>
> If it matters, changing my test script to use "trap" to just exit on a
> signal didn't make any difference.

Probably your "script" is not a script but a text file containing
shell commands that you source.

The trick to avoid having it kill your shell, is to have it run in its
own shell (which it is free to kill).  To do so, you must put:

#!/bin/bash

on the first line of the "script", and you should change the access
rights to give it executable rights:

chmod +x script


Then you can launch it as:

./script

instead of 

. script # or source script


When you launch it like this, the kernel notice the #! characters at
the beginning of the file, and therefore forks a process running
/bin/bash, which will execute the rest of the script.  When that
script exits or kills itself, it only kills the bash launched by the
kernel, and not the bash running in emacs.


-- 
__Pascal Bourguignon__


reply via email to

[Prev in Thread] Current Thread [Next in Thread]