Re: Copy folder shell scripting
Re: Copy folder shell scripting
- Subject: Re: Copy folder shell scripting
- From: Christopher Nebel <email@hidden>
- Date: Thu, 24 Apr 2008 09:24:12 -0700
On Apr 24, 2008, at 7:35 AM, Mark J. Reed wrote:
You can put any kind of interpreter name after the #! and it will
work,. for instance
#!/usr/bin/osascript
path to me
works (at least on Leopard; a niggling memory is telling me that you
might have to add an option after the /osascript to get it to work on
earlier versions of OS X).
Actually, it just doesn't work in earlier versions. It's possible to
fake it, though; here's one way:
#!/bin/sh
osascript - "$@" <<EOF
your script here
EOF
An executable file beginning with "#!something" will execute
"something", passing it the name of the original file as its last
parameter. Read execve(3) for all the details.
However, the #! line is itself included in the input fed to the
interpreter, so this trick won't work if the interpreter is confused.
# is normally a comment to the shell, so that's not a problem, but
programs like osascript have to have the ability to handle that line
built in.
The #! (pronounced "shebang"; yes, really) line relies on interpreter
treating "#" as a comment-to-end-of-line character. It's a common
feature of Unix-based languages for this reason. AppleScript prior to
Leopard didn't have that; now it does. There's nothing in osascript
to handle it; it's built into AppleScript. This was partly for
consistency, but more because that way you can write your script in
Script Editor with the shebang intact and not worry about it.
--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