[prev in list] [next in list] [prev in thread] [next in thread] 

List:       bash-bug
Subject:    Re: tricky shell script question
From:       prj () po ! cwru ! edu (Paul Jarc)
Date:       2008-02-12 21:44:07
Message-ID: m3d4r16e9t.fsf () multivac ! cwru ! edu
[Download RAW message or body]

"Erik-Jan Taal" <erik.taal@wmfs.net> wrote:
> Now watch the terminal where the script was still running. I would
> expect no output to be given, as I assumed the script is read into memory
> at startup and not during execution and this is what happens on most 
> systems. On one server however, the 'bla' is echoed.

There are no guarantees here, except that each top-level statement is
entirely read before being executed.  Reading beyond the next command
to be executed can vary from one system to another, depending on stdio
buffering from libc.  So if you want to be sure that each execution
isn't affected by edits made while it is running, wrap the whole thing
in a compound statement that exits before returning:

#!/bin/sh
{
...
exit
}


paul



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic