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

Re: RfD: Policy of .sh boot scripts



In article <cistron.19981021122618.C23145@kuolema.Infodrom.North.DE>,
Martin Schulze  <joey@infodrom.north.de> 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

        case "$i" in
                *.sh)
                        # Source shell script for speed.
                        (
                                trap - INT QUIT TSTP
                                set start
                                . $i
                        )
                        ;;

Now, an exit in a subshell [ in ()] will just exit that subshell. Proof:

$ sh -c 'echo foo; ( exit ) ;  echo bar'
foo
bar

So there is no problem with exit in *.sh scripts. You can even press
control-c in a sourced script, and it will only interrupt the sourced
script and not /etc/init.d/rcS

I've carefully thought this over, bummer that I forgot about it ..
My memory's like a siefe .. (English expr?)

Mike.
-- 
  "Did I ever tell you about the illusion of free will?"
    -- Sheriff Lucas Buck, ultimate BOFH.


Reply to: