preventing slackware services from auto starting
Adam Myrow
amyrow at midsouth.rr.com
Mon Sep 5 10:38:08 EDT 2005
On Mon, 5 Sep 2005, Steve Holmes wrote:
> Why is that first period necessary? I've seen that from time to time in
> Slackware startup scripts but I never knew why and when I've added
> commands to my own startup scripts, I usually leave it out with no known
> effects.
I don't know if it's strictly necessary, but it does change the behavior.
Normally, if you execute a shell script by typing its name, it will run in
a subshell, which will be determined by the "#!" line at the top of the
script. For example, if the top line says "#!/bin/sh," it runs in
/bin/sh, which is normally a symbolic link to Bash under Linux.
If, on the other hand, you invoke the script with a period by itself at
the beginning of the line, the script runs in the current shell, and the
"#!" line is treated as a comment and ignored. This is how .profile is
ran at login. This has both advantages and disadvantages. The obvious
disadvantage is that if the script is intended for Perl, or Tcsh, it will
bomb out with this method since the current shell tries to interpret it.
The big advantage is that any environment variables you set will remain
after the script quits. That's why export commands in your .profile will
work, but if you try them in another script, and invoke it without the
period, they will vanish once the script exits. Exported variables are
available to child shells, but not parent shells. This makes it very
difficult to pass variables from a script back to the parent shell, unless
you source it so that it runs in the current shell. Hope this explains it
clearly. My suspicion is that Slackware is sourcing the other startup
scripts in order to keep the number of processes down at boot time.
More information about the Speakup
mailing list