• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Scripting Additions: Embracing the Horror of Unix
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Scripting Additions: Embracing the Horror of Unix


  • Subject: Re: Scripting Additions: Embracing the Horror of Unix
  • From: garbanzito <email@hidden>
  • Date: Sun, 3 Feb 2002 12:18:00 -0700

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.
[...]

To inspect the condition of the environment variables, you can run a script:

do shell script "set > ~/Documents/doShellSettings"

which will deposit the contents of all your environment variables into the file "doShellSettings" in your "Documents" folder. You should see that

$0=sh

Meaning that the call used to create this environment was "sh".

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"

(instead of redirecting standard output, i just examine the
script result window.) here are the relevant lines of the
result:

PID PPID COMMAND
[...]
1101 72 /Applications/AppleScript/Script Editor.app/Contents/MacOS/Script Editor -psn_0_2621441
[...]
1189 1101 ps -axwwopid,ppid,command

note that the parent process id (PPID) of ps is the process
id (PID) of Script Editor. if ps were run via sh, then a sh
process would be the parent. so Script Editor is directly
launching the ps command. for those less familiar with unix,
run the same ps command in a Terminal window and you'll see
the ppid of the ps command corresponds to a shell process
(tcsh unless you've changed your shell).

thus my contention that "do shell script" must use one of
the exec() functions. these are BSD system calls that allow
a program to launch another program similarly to how it is
launched from a shell. i had thought maybe execv(), but i
have only superficial knowledge of unix system calls -- the
man page makes me now think it's execvp() or execlp().
(they're all listed by "man 3 exec").

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.

--
steve harley email@hidden


References: 
 >Re: Scripting Additions: Embracing the Horror of Unix (From: Oliver Sun <email@hidden>)

  • Prev by Date: Re: Scripting Terminal
  • Next by Date: Re: Scripting Terminal
  • Previous by thread: Re: Scripting Additions: Embracing the Horror of Unix
  • Next by thread: Re: Scripting Additions: Embracing the Horror of Unix
  • Index(es):
    • Date
    • Thread