Re: Scripting Additions: Embracing the Horror of Unix ($0=sh)
Re: Scripting Additions: Embracing the Horror of Unix ($0=sh)
- Subject: Re: Scripting Additions: Embracing the Horror of Unix ($0=sh)
- From: Oliver Sun <email@hidden>
- Date: Mon, 4 Feb 2002 11:39:44 -0500
Date: Sun, 3 Feb 2002 12:18:00 -0700
To: Oliver Sun <email@hidden>, email@hidden
From: garbanzito <email@hidden>
Subject: Re: Scripting Additions: Embracing the Horror of Unix
at 2002 02 02, 16:13 -0500, they whom i call Oliver Sun wrote:
It appears upon some inspection that "do shell script" actually
calls the default shell "sh" as a non-login shell.
[...]
i went over this a couple weeks ago in a post many people
may not have read. i believe there is no sh process. i
suspect $0=sh is just a misleading artifact. try:
do shell script "ps -axwwopid,ppid,command"
if ps were run via sh, then a sh
process would be the parent. so Script Editor is directly
launching the ps command.
Without passing the quoted script to bin/sh or some other command
interpreter, how does the AppleScript manage to call commands such as
"pwd" or "echo", or perform wildcard expansions, all of which are
built-in shell features and _not_ separate programs (unlike "/bin/ps")?
so, regarding the treatment of quotes in arguments to a unix
command, it would be helpful to know how exactly "do shell
script" launches a process, and what treatment the command
line arguments will get.
Type exactly:
do shell script "echo 'My home is not $HOME'"
and
do shell script "echo My home is $HOME"
and note the difference.
The exact process by which Script Editor manages to do the shell script
is a minor mystery, but it does not appear to be appreciably different
from what a shell process does for direct execution -- fork(), then
execute the command in the child process and terminate. In this case,
AppleScript need to spawn
Cheers,
Oliver M. Sun
Indiana University/UITS