[PLUG] Probing init scripts...
Paul Heinlein
heinlein at madboa.com
Tue Aug 26 22:08:02 UTC 2003
On Tue, 26 Aug 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?
In general, when faced with an unfamiliar command in a shell script on
a Linux host, you'd be well served to try the standard sources of
help.
It's very important to note that the shell may have a builtin version
of a utility that also exists as its own binary: echo, false, kill,
pwd, test, and true are a few that come to mind.
E.g, calling "kill" within a bash script can be subtly different than
invoking "/bin/kill" directly. At a command prompt, for example, type
"kill -l" and then "/bin/kill -l" to see the variations in the sort of
signals they can recognize.
So, for any command "foo" you'd first check the shell's help system
and then, failing that, check for a standalone man page.
1. Try using bash's help system:
[host]$ help foo
2. If it shows up in the help system, but you need more info, then
search for "foo" in the bash man page:
[host]$ man bash
If you use less for viewing man pages (e.g., by setting the PAGER
environment variable), then you can search for a whole-word match:
/\<foo\>
The '/' puts you into search mode, and the \< and \> act as
word-boundary markers, so that "fool" wouldn't match, but "foo."
and "(foo)" would.
3. If you can't find it in the shell literature, try looking for a man
page:
[host]$ man foo
4. Poke around the two wonderful LDP HOWTOs concerning shell
scripting:
beginning: http://www.tldp.org/HOWTO/Bash-Prog-Intro-HOWTO.html
advanced: http://www.tldp.org/LDP/abs/html/index.html
5. Ask PLUG. :-)
--Paul Heinlein <heinlein at madboa.com>
More information about the PLUG
mailing list