• 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: Integrating Unix scripting in Cocoa app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Integrating Unix scripting in Cocoa app


  • Subject: Re: Integrating Unix scripting in Cocoa app
  • From: Craig Hunter <email@hidden>
  • Date: Tue, 07 Aug 2007 17:09:11 -0400

> There's something wrong with your test script. 'source' performs no
> such interpretation; it simply loads the file as a shell script into
> the running shell. Try it with the following Python script, for example:
>
> #!/usr/bin/env python
> import sys
> print repr(sys.argv)
>
> On most systems, this'll fail with "import: command not found". If
> you've got ImageMagick installed, it'll do even stranger things.

--

#!/bin/tcsh
echo 'hello world'

--

Obviously your example needs python invoked to interpret the subsequent
commands -- I am not sure I would consider that a shell script.  The source
command will only work if you pass it shell commands that the
current/default shell can interpret.  Presumably, if a user submitted a text
file to be run as a script, and they give no other directives (shebangs,
shells, or interpreters to use), then they are probably intending it to be a
script for their default shell.  So I would say test for a
shebang/interpreter specification and execute bits, and then resort to
"source" as a fallback.  In lieu of the shebang and it's associated
interpreter, there is no other way to really know how to treat the file
anyhow.  Of course this may still fail if the user wrote the script for a
shell other than what they set as their default (if the app even checks for
that), but you can only bend over backward so far in this case.

Craig


--
Dr. Craig Hunter
NASA Langley Research Center
Configuration Aerodynamics Branch
email@hidden
(757) 864-3020

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Re: Integrating Unix scripting in Cocoa app (From: Andrew Farmer <email@hidden>)

  • Prev by Date: Re: Integrating Unix scripting in Cocoa app
  • Next by Date: Re: Cocoa callback handling
  • Previous by thread: Re: Integrating Unix scripting in Cocoa app
  • Next by thread: Re: Integrating Unix scripting in Cocoa app
  • Index(es):
    • Date
    • Thread