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

Re: RfD: Policy of .sh boot scripts



In article <cistron.19981020203126.O3402@finlandia.infodrom.north.de>,
Martin Schulze  <joey@infodrom.north.de> wrote:
>In /etc/* there are severeal scripts that are named *.sh.  Most of
>them are not marked executable and don't contain a "#! /bin/sh" line.
>
>Thus, to run them you need to "sh foo.sh" or "source foo.sh" them.
>This raises a problem if the script contains code like "test -x foo ||
>exit 0".  This would cause the executing shell to be terminated if it
>uses source to run the script.

I would like to mention the following:

- I introduced this since this is what Solaris does and I
  blindly copied the whole /etc/rcS.d setup from Solaris,
  including the "source .sh scripts" convention
- It speeds up the boot process, Debian boots slow enough
  as it is at the moment.

> a) Scripts in /etc/init.d, /etc/rc.boot and similar directories that
>    have the ".sh" suffix may be run by source'ing them.  Thus they
>    must not contain any `exit' statements.  If they need to quit the
>    script they have to use return instead
>
> b) All scripts in /etc/init.d, /etc/rc.boot and similar directories
>    have to be standalone shell scripts.  They must have the 'x' flag
>    turned on and contain a regular command to execute them in the
>    first line (such as "#! /bin/sh").  They must not be called *.sh.
>
>A mixture of this does not make sense imho:

And is impossible - since return doesn't work in a normal script.
Ash doesn't complain about it but bash does:

$ sh -c return
sh: return: can only `return' from a function or sourced script

$ ash -c 'echo hello; return; echo foo'
hello

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


Reply to: