• 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: Why is the initial working directory of 'do script' root? Was: Interacting with external shell scripts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why is the initial working directory of 'do script' root? Was: Interacting with external shell scripts


  • Subject: Re: Why is the initial working directory of 'do script' root? Was: Interacting with external shell scripts
  • From: Christopher Nebel <email@hidden>
  • Date: Tue, 12 May 2009 11:25:01 -0700

On May 11, 2009, at 4:52 PM, Anthony Adachi wrote:

Who or what is determining the initial working directory of the 'do

shell script' command?

See: <http://developer.apple.com/technotes/tn2002/tn2065.html> for the straight-goods on 'do shell script'.

Interesting. I gather the default current working directory is not something that can be relied upon?

That depends on who's asking -- TN2065 is a little unclear on this point. It says that the working directory is inherited from the process' parent; this is perfectly true.


For a normally-launched application, neither the parent nor its working directory is well-defined. These days it's launchd(8) and /, but that's changed a few times in the past, may change again, and isn't under user control, hence the warning to not rely on it.

For a process launched from a shell such as osascript(1), however, the working directory *is* well-defined -- it's, well, the working directory of the shell -- so you can rely on that. However, that's not a particular location, it's whatever the shell user set it to, so you can "rely" on it only in the same sense that any shell script could.


--Chris Nebel AppleScript Engineering


_______________________________________________ Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
References: 
 >Interacting with external shell scripts (From: "Anthony Adachi" <email@hidden>)
 >Re: Interacting with external shell scripts (From: "Mark J. Reed" <email@hidden>)
 >Why is the initial working directory of 'do script' root? Was: Interacting with external shell scripts (From: "Anthony Adachi" <email@hidden>)
 >Re: Why is the initial working directory of 'do script' root? Was: Interacting with external shell scripts (From: Philip Aker <email@hidden>)
 >Re: Why is the initial working directory of 'do script' root? Was: Interacting with external shell scripts (From: "Anthony Adachi" <email@hidden>)

  • Prev by Date: Re: Script to conditionaly uncheck Hide and show Front Row
  • Next by Date: Re: Script to conditionaly uncheck Hide and show Front Row
  • Previous by thread: Re: Why is the initial working directory of 'do script' root? Was: Interacting with external shell scripts
  • Next by thread: Re: Interacting with external shell scripts
  • Index(es):
    • Date
    • Thread