help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Editing a running bash script can cause it fail?


From: Pierre Gaston
Subject: Re: [Help-bash] Editing a running bash script can cause it fail?
Date: Mon, 27 May 2013 09:10:10 +0300

On Mon, May 27, 2013 at 5:59 AM, Chris Down <address@hidden> wrote:
> I'm not totally sure how it happens or what the conditions for re-reading
> the script are, but it is known[1].
>
> PS (to Chet, et al): is this documented in detail somewhere? This seems like
> one of the few things that I've not been able to find functional
> documentation on, whether in the bash manuals, or elsewhere.
>
> 1: http://stackoverflow.com/a/6303416/945780
>
>
> On 27 May 2013 10:54, Peng Yu <address@hidden> wrote:
>>
>> Hi,
>>
>> It seems that a bash script is not first load into memory completely
>> and then get run. Is it the case? I think that this is true because
>> modifying a running bash script sometimes causes the existing run of
>> the script fail.
>>
>> If so, is there a way to let bash read a script completely before
>> running it so that editing the script will not cause the run fail?
>> Thanks.
>>
>> --
>> Regards,
>> Peng

I don't think it's really known. IIRC ksh93 reads the whole file while
bash does not (though on small script it might appear as if it does)

In any case I would not rely on editing a script while it's running.

If the goals is to replace a running script, you can safely* remove
the original file and replace it with a new file.
The script will continue to use the old script file until it exits, if
I'm not mistaken bash doesn't reopen the script file multiple times.


* of course you should take into account what happens if the new file
cannot be copied for some reason



reply via email to

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