On Jul 28, 2005, at 11:10 PM, John Horner wrote:
and it seemed to work, but leaving aside the specifics of the scripts, how would Perl "know" that I use tcsh, not bash?
As others have already said, Perl knows there's an environment variable, but it neither knows nor cares how that variable got set.
Isn't that a preference of the Terminal app, not of me as a user?
Actually, no. It's a preference of the user. If you log in by other means - X11's xterm, or remotely through ssh, for instance - the same preference will be used.
A script run as a cron job, does it run using all the environment variables as if I'd typed its name into the Terminal?
No. As it says in "man 5 crontab", only LOGNAME (aka USER on some systems), HOME, and SHELL are set. You may set others by adding name=value pairs to your crontab file.
See "man 5 crontab" for details.
What about a script run from BBEdit?
BBEdit is a GUI app, and GUI apps don't use your login shell. To define environment variables to be used by GUI apps, have a look at this Q&A from Apple:
<http://developer.apple.com/qa/qa2001/qa1067.html>
What if I "su root" and run it?
It depends. If you simply "su" to root, you'll keep the same environment. But, if you "su -" (note the dash), it's like you're starting a separate new login session - root's own user login scripts are run, and nothing is inherited.
Sudo begins with an inherited environment, but modifies it heavily - have a look at the "Security Notes" section in "man sudo" for details.
sherm-- Cocoa programming in Perl: http://camelbones.sourceforge.net Hire me! My resume: http://www.dot-app.org
