[PLUG] Probing init scripts...
Kyle Accardi
sandbox at pacifier.com
Tue Aug 26 21:19:02 UTC 2003
Michael C. Robinson wrote:
> # 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?
Since this is presumably a bash script, $1 is the list of arguments supplied
to the script from the command line (it's hardcoded into bash). 'shift'
steps through them using <space> as a seperator (although this can be
changed through the environmental var $IFS which stands for Internal Field
Seperator).
So if you call your script thusly,
$ my_script foo bar baz
the while loop above will be entered three times, and $1 will hold the
values foo, bar, baz in that order.
I'd answer the rest, but my dog insists on playing right now...
--
Kyle Accardi
More information about the PLUG
mailing list