According to Martin Schulze: > Miquel van Smoorenburg wrote: > > In article <[EMAIL PROTECTED]>, > > Martin Schulze <[EMAIL PROTECTED]> wrote: > > >So regular *.sh scripts must not contain any "exit" statement. > > >(which is the case e.g. for keymap.sh) > > > > Ah, now I remember. This has been solved quite some time ago. > > *.sh scripts may contain an "exit" statement, because they are run > > in a subshell. Fragment from /etc/init.d/rcS > > They don't need to be run in a subshell.
Yes they do. You reall want to be able to press Control-C to interrupt only that fragment without killing of the whole /etc/init.d/rcS script. For that, you need to disable SIGINT in the rcS script and run the fragment (.sh file) in a subshell with SIGINT enabled. That exit then also gives no problems is a nice coincidence .. > When they would have to run in a subshell I don't see a reason for > not making them work standalone. sh script.sh is very different from running it in a subshell with (). For example, bash doesn't really fork a new invocation - it just sets up a new internal environment temporarily. It's a speed optimization. > (Calling the user an idiot and > preventing him from executing them manually is not a reason.) There's no need to become abusive, even though this is the policy mailing list :) > Btw. when we discuss boot scripts you should not always depend on > sysvinit owning the one and only method of booting the system. > Please always keep in mind that there is also file-rc. There might > be r2d2 in the future as third method. I'm only taking Solaris as an example, because it works. But I understand what you mean. BTW, what's r2d2? > > Now, an exit in a subshell [ in ()] will just exit that subshell. Proof: > > Proof for this being not the one and only is one of the latest > bugs agains kbd. I bet the user who reported that bug uses an old sysvinit in which this change wasn't made in /etc/init.d/rcS. > > So there is no problem with exit in *.sh scripts. You can even press > Yes there is. No there isn't. Mike. -- "Did I ever tell you about the illusion of free will?" -- Sheriff Lucas Buck, ultimate BOFH.