Re: Multi-line do shell script. How?
Re: Multi-line do shell script. How?
- Subject: Re: Multi-line do shell script. How?
- From: Christopher Nebel <email@hidden>
- Date: Thu, 22 Apr 2004 12:37:55 -0700
On Apr 22, 2004, at 5:42 AM, Doug McNutt wrote:
At 00:14 -0400 4/22/04, Graff wrote:
Ahh ok. I'm mostly a tcsh person so I'm used to using setenv. I got
the "declare" command from the bash man pages and when I tested the
command it did give me a listing of all my environment variables so I
figured that was it.
bash and sh are links to the same executable module. My understanding
is that, when called as sh, bash behaves in a manner compatible with
the "original" UNIX shell. Perhaps declare is a bash-only call.
I didn't check carefully enough before claiming "declare" wouldn't work
-- it does. Theoretically, bash emulates sh when invoked as "sh", but
it still allows bash-isms where they don't conflict. Whether or not
this is a bug depends on your perspective, but I'd guess that the GNU
folks are unlikely to change it.
It's still not clear to me just how AppleScript calls "the" shell and
what commands and environment variables are actually available.
Actually learning sh/bash would probably help. A tech note that says
it calls "sh" is precise, but one still wonders "which sh?" when there
are user defaults and the English-like nature of AppleScript to
consider.
Quoting from TN2065:
Q: What shell does do shell script use, really?
A: do shell script always calls /bin/sh. However, in Mac OS X, /bin/sh
is really a copy of another shell that emulates sh. In 10.2 and later,
this is bash; prior to that it was zsh.
Is that clear enough for you? AppleScript invokes your command by
calling execve("/bin/sh", { "sh", "-c", your-command },
*(_NSGetEnviron())). That means that the sh process gets the
environment of the host application (i.e., the one you told to "do
shell script"). Because it is invoked as a non-interactive, non-login
shell, it does not execute /etc/profile or ~/.profile, and because it's
invoked as sh, it does not attempt to execute any other startup files.
See sh(1) under the INVOCATION section for all the details.
--Chris Nebel
AppleScript Engineering
_______________________________________________
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.