At WWDC last year I presented a session on BSD in Mac OS X, and I came 
up with a demo at the last minute (as usual) for it in which I tried to 
demonstrate why having a BSD runtime environment (the command line 
toolset) in Mac OS is a cool thing, even if you never use the command 
line.  As is my habit, I also try to sneak in a plug for why Cocoa kicks 
butt as a toolkit with which one can wrap up a scary nasty Unix thingy 
and make it look and feel much like a spiffy warm-and-fuzzy Mac OS 
thingy.

   The demo I wrote is a small application called DropScript.  You drop 
any executable program (for example, a shell script, a perl script, a C 
program, ...) onto the DropScript app icon (or launch DropScript and use 
the open panel), and DropScript will create a new application using your 
program.  The new application, in turn, can be used in Finder to run 
your program on files.  For example, you can write this shell script:

        #!/bin/sh
        gzip -9 -- "$@"

   Save it as GZip.sh.  Drop this on DropScript, and you get a new 
program (in the same location as the script) called DropGZip.sh.  Drop 
any file onto DropGZip, and it will compress the file using GZip for 
you.  You could also get similar results (sans the -9 option; and 
the '--' keeps it from complaining about files that begin with '-') by 
simply dropping the gzip executable itself onto DropScript.  But shell 
scripts a smaller and far more flexible than binaries.

   For cooler examples, see Shove.sh and UnShove.sh in the Resources 
directory within the app wrapper; they will create and unpack tar+gzip 
archives ("ShoveIt Deluxe"); these are somewhat better versions of the 
demo I did at Mac Hack, for those of you who were there.

   For those of you familiar with MacPerl, one of the cool things MacPerl 
could do is to make Perl droplets in Classic Mac OS.  This enables 
similar functionality in Mac OS X for perl and pretty much any language 
environment you like.

   You can get a pre-built DropScript app from:

        ftp://isp.mit.edu/users/tritan/MacOSX/DropScript-0.2.dmg.gz

   You can get source from the Darwin CVS repository, project 
"DropScript".

   It lacks docs, though it's pretty simple.  It also doesn't accept 
folders when you drag them onto the icon with Finder (is there an OS 
type for folders I need to add?), though the open panel should allow you 
to select folders.

   If you are a programmer, check out the source; it's a rather 
impressive feat of simplicity.

        -Fred

Wilfredo Sánchez - [EMAIL PROTECTED]

Reply via email to