[PLUG] Probing init scripts...

Felix Lee felix.1 at canids.net
Tue Aug 26 21:18:02 UTC 2003


"Michael C. Robinson" <michael at goose.robinson-west.com>:
> # Check if $pid (could be plural) are running
> checkpid() {
>         while [ "$1" ]; do
>            [ -d /proc/$1 ] && return 0
>            shift
>         done
>         return 1
> }
> What is shift doing here?  Some kind of bit shifting?

shifts the arguments to the function.  when you call
    checkpid a b c d e
then, inside checkpid, $1 is 'a', $2 is 'b', etc
after you shift, $1 is 'b', $2 is 'c', etc.

> if [ "${BOOTUP:-}" != "verbose" ]; then
> What's going on with ${BOOTUP:-}?  Is the latter

${var:-foo} is a notation that means "if var is non-null, then
substitute its value, otherwise substitute foo".

There's no particular reason to use that notation here.
"$BOOTUP" would be fine.

All of this is described in detail in the bash man page.

shift is in the section "SHELL BUILTIN COMMANDS".

${} is in the section "Parameter Expansion".

> What is the overall purpose of the functions script?
> I'm trying to decipher rc.sysinit to see how I might
> modify for booting via nfs-root instead.

You should find an intro to shell programming.  Those are very
basic questions you're asking, and you probably won't get far
without some general knowledge of how shell scripts work.
--




More information about the PLUG mailing list