Mailinglist Archive: opensuse (818 mails)

< Previous Next >
Re: [opensuse] different types of shell scripts
Roger Oberholtzer said the following on 09/22/2011 07:22 AM:

Not really. If the script changes, say, the PATH, it will then be
changed for your shell as well. You may also wind up in some other place
when it is done.

A very good point.
This is why you should always run as sub-processes of the command line.

Its reasonable for a sub-process script to source something. We can see lots of examples of the in /etc/init.d/* All perfectly valid because they run as sub-processes so don't affect the calling process.

> Sourcing a script should only be done if the script is
intended specifically for this purpose.

Such as .profile (and variants)

I would never do this to a
script that installs software.

In fact I'd never do it with a script that I hadn't audited to be sure it wasn't going to do odd things to my environment; which means be very careful when running externally supplied code as root.

We succeed only as we identify in life, or in war, or in anything else, a single overriding objective, and make all other considerations bend to that one objective.
Dwight D. Eisenhower, speech, April 2, 1957
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx

< Previous Next >