• 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: Ron Fleckner <email@hidden>
  • Date: Tue, 7 Aug 2007 22:30:19 +1000


On 07/08/2007, at 10:01 PM, Kevin Kuehl wrote:

--- Ron Fleckner <email@hidden> wrote:

At the moment, I'm assuming
that the shebang line is the FIRST line of the
script which makes it
easy to find.

The '#!" not only has to be on the first line, the two characters also have to be the first two in the file. They are a special case for UNIX magic numbers. Please see: http://en.wikipedia.org/wiki/Sha-bang for more information.

My question: Do people ever write shell scripts
without a shebang
line or where the shebang line is NOT the first line
of the script?

The only time I ever leave it out of shell scripts is when I write code fragments that are not to be executed on their own. For example, if a script is meant to be sourced into another one, I'll leave it out as a reminder not to try to execute the script.

If '#!' are not the first two characters in a file,
there's not much you can do.  If you can determine
it's a text file, you could probably try sending it to
/bin/sh and see what happens.  I don't think making
the demand that the script either starts with a '#!'
or is a /bin/sh script is too unreasonable.  There is
a lot of history to support this choice.

Kevin Kuehl
email@hidden

Thanks, Kevin. I thought that having '#!' as the first two characters was required, but needed to check whether that was indeed the case. I agree that having them there is not an onerous requirement for the type of user who would be writing scripts. I haven't yet tried out a shell script. I'll have to have a look for an example of "Hello world" for each of bash, sh, ksh &etc to see if they work as well.


Ron
_______________________________________________

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: Kevin Kuehl <email@hidden>)

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