Scripting Additions: Embracing the Horror of Unix
Scripting Additions: Embracing the Horror of Unix
- Subject: Scripting Additions: Embracing the Horror of Unix
- From: Jon Pugh <email@hidden>
- Date: Mon, 28 Jan 2002 22:36:31 -0800
So I've been trying to exist running just X at work, and it's obnoxious. I've wasted a bunch of time trying to do my work in old ways with new tools but it's kind of fun making new tricks out of old tools.
Luckily, I've got friends along for the ride. BBEdit is pulling its weight as usual, with its new shell worksheets combining one of the best parts of MPW with the awesome cosmic power of unix shells. I've even got stationery that contains all my common shell commands, just like I was doing with MPW.
However, I've had a bit of an epiphany I thought I would share.
These unix shells will probably make most scripting additions unnecessary.
Right now, Mac OS X ships with the "do shell script" scripting addition. I've also seen several other third party editions that do the same thing. Hopefully they will die now that there's a system implementation, but that's not important right now.
The key is that much of Jon's Commands can be replicated with shell commands.
For example, the copyFile command is thus:
set sourceFile to "Disk:folder:folder:file"
set destinationDir to "Disk:folder:folder:folder:"
do shell script ("cp " & posix path of sourceFile & space & posix path of destinationDir)
Now, granted that this doesn't do everything my wonderful command does, and the syntax is even more obtuse, but the point is, most of what people need can be done using shipping tools and some modified scripts. For goodness sake, you can run perl scripts this way too. It's pretty wide open, and gives AppleScript pretty much unlimited unholy power. Hopefully there's no viruses lurking in this realm's future.
Of course, cosmic unix power doesn't get you anything like the way cool implementation of things like "walk folders" which doesn't have any corresponding unix tool with the simplicity it provides. Well, that's keeping me convinced that I will port Jon's Commands some day, but don't go getting all eager or nothing. ;)
I'm just saying that I don't really see the need to port the entire collection, with the possible exception of compatibility, so that other people don't need to rewrite their scripts. Well, some of them *are* paying customers, so I haven't ruled out a complete carbonization, but I just don't see the value in maintaining third party solutions for problems which have a built in solution.
And so, I am considering the death of Jon's Commands. Or more likely, it's rebirth as something completely different and yet disturbingly similar.
Much of Jon's Commands was designed to either work around limitations or take advantage of the strengths of AppleScript and the MacOS. Some of them would still be useful and/or applicable in MacOS X, while others would not.
Let's examine with the list of Jon's Commands:
Stuff you can do with the shell:
deleteFile: Delete a file or folder.
renameFile: Rename a file or folder.
moveFile: Move a file or folder.
copyFile: Copy a file.
Stuff in the System now:
sound volume: Returns the current system sound volume.
set sound volume to: Sets the current system sound volume.
clipboard info: Get information about the clipboard.
set the clipboard to: Place data on clipboard.
the clipboard: Get value of clipboard.
AppleScript specific stuff:
walk folders: Execute a script on each file in a folder subtree.
AE user interaction level: Change the user interaction level.
Stuff that is still useful:
play sound: Play an snd format sound.
execute FKEY: Run an FKEY resource.
the ticks: Return the current tick count.
keys pressed: Get the keys that are currently pressed.
machine environment: Information about the running machine.
alias information: Return information about an alias or alias file.
screen list: Return a list of screen statistics.
set screens to: Change the screen depths, resolutions and layouts.
choose color: Use the color picker to choose a color.
Stuff that probably isn't useful in X:
run script resource: Run a script resource.
free memory: Return available free memory.
set cursor to: Change the cursor.
keyboard lights: Get and set the extended keyboard9s lights.
snag object: Save the object specifier in the direct parameter to a file.
fileIsBusy: Return whether or not a file is open.
Given this list, I see only 11 commands that really need porting. AppleScript specific stuff and Stuff that is still useful.
That ought to spark a debate. ;)
Now, I'll bet some of the useful stuff above can be done with the shell, and more will be done with time, as new shell commands are integrated into the system, but there's still some value there at the moment.
So Jon's Commands isn't dead yet, but it's not imminent either.
Jon