Re: Fink and 'sh'
Re: Fink and 'sh'
- Subject: Re: Fink and 'sh'
- From: Doug McNutt <email@hidden>
- Date: Tue, 23 Mar 2004 07:07:23 -0700
At 23:18 -0500 3/22/04, Graff wrote:
>
However when I do:
>
do shell script "tcsh -c 'echo $PATH'"
>
I get:
>
/sw/bin:/sw/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/currentuser:/usr/ X11R6/bin
What's happening is that AppleScript is using bash as a default. It ignores anything you ask for in your Aqua login preferences. bash then sees the command line that starts with "tcsh" and starts up a non-login copy of tcsh which executes - er, sources - $HOME/.tcshrc. You can see this if you echo $SHLVL for which you will see a value 2 meaning you're two levels deep into shells. Try inserting an echo or two, redirected as >> $HOME/shellog, into your .tcshrc file to experiment with all the shelling that goes on.
The only way to set environment variables that are in place BEFORE you execute a do_shell_script is through the environment.plist mechanism. Shell variables you set in a first do_shell_script are lost before executing a second even within the same AppleScript. AppleScript does not offer an equivalent of the "source" command in tcsh.
It is all very frustrating to those of us who, in the 70's, became accustomed to having a login file run when you login to a computer and not when you open Terminal.app. And don't bother running, say, Script Editor with an open command from a Terminal session. That will forget your environment too. And don't bother rewriting environment.plist on the fly to change a global environment variable. It's only read at login_to_Aqua time. And, one more, Linux distributions seem have the same kind of problems if you choose to use the GUI's provided as desktops.
And yet one more. If you set a PATH variable in environment.plist and then startup Terminal.app with tcsh a global login file in /etc/ will be executed and will overwrite your chosen PATH. It's easily fixed by removing or modifying the single line in the /etc/ file but it can really fool you.
--
Applescript syntax is like English spelling:
Roughly, but not thoroughly, thought through.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.