Fwd: Re: Scripting Additions: Embracing the Horror of Unix
Fwd: Re: Scripting Additions: Embracing the Horror of Unix
- Subject: Fwd: Re: Scripting Additions: Embracing the Horror of Unix
- From: email@hidden (Michael Sullivan)
- Date: Fri, 1 Feb 2002 17:45:23 -0500
- Organization: Society for the Incurably Pompous
Shane Stanley <email@hidden> writes:
>
On 2/2/02 3:48 AM +1000, Michael Sullivan, email@hidden, wrote:
>
>
> Is this kind of what you're thinking of Shane?
>
>
Not really. I don't have any particularly view about how scripting of the
>
shell is done. To do it, you obviously have to understand a certain amount
>
of unix, and as someone pointed out, abstracting all that to AS would be (a)
>
futile and (b) probably counter-productive.
>
(The fact that, in all this discussion, no-one has come up with a complete,
>
robust, ready-to-be-copied-and-pasted handler for any of the missing Jon's
>
commands suggests it's either not particularly straight forward, or so
>
simple I'm missing the bleeding obvious.)
I wouldn't say that. Something that's been robust enough for unix users
for years is the 'rm -f filename', or 'rm -Rf directoryname' that Greg Strange
posted yesterday.
Steve suggested that the recursive form could be dangerous if you
have links. If it follows them, then he'd be right, you'd have to
either find a utility that won't follow the links or hopefully a switch
in rm or just be aware of it when you call the routine.
I looked and the SCO server we run here doesn't mention this issue at
all in the rm man page, so clearly there's no switch for it on that, and it's
not clear whether it's an issue there, which still doesn't answer the question
for OSX.
Anyway, if you were willing to live with that potential danger, I'd do a
simple handler for delete file based on rm, except that I'm not running
X right now, so I can't test it. All I can do is write something that I
*think* will work.
To do something that exactly duplicates all of the safeguards built into
Jon's DeleteFile on OS 9 (mostly inherent in the APIs, I suspect), would
be fairly complicated. I think you'd basically have to rewrite a walk
folder routine that specifically didn't follow links, etc.). If you're
talking about single files, then the simple handler ought to work, but I
don't plan to foist one on the list without doing even simple unit
testing. Have you looked at KinderShell? Will that do what you need? Is
there someone running X who can test the simple handler:
on DeleteFileWithExtremePrejudice(theFile)
try
do shell script "rm -f " & (quoted form of POSIX path of thefile)
on error
return
end try
end DeleteFileWithExtremePrejudice
If this script does what I think, it will simply do nothing if you pass it a
folder, and delete completely any file that's passed. Obviously needs testing,
and I'd check what happens when you use it on an alias or symbolic link that's
linked to nothing important before putting it into production.
on DeleteFolderWithExtremePrejudice(theFolder)
try
do shell script "rm -Rf " & (quoted form of POSIX path of theFolder)
on error
return
end try
end DeleteFolderWithExtremePrejudice
Likewise, this should take out a whole folder -- test to see what happens with
aliases/links and whether it gets the folder itself, as Steve H. suggested.
And just generally needs to be tested. I'm using my fairly rusty knowledge of
other BSD OS's and syntax I've seen from OSX people here and on the X server
list to write these. Even if they are basically correct, Chris's posts make me
think you might need to wait for the production version of 1.8.2 to make these
work without tweaking.
>
My concern is that shell scripting not be seen as the answer to every
>
scripting request. I think there's still a role for scripting additions,
>
perhaps without all the switches the shell offers, so scripters rarely *have
>
to* resort to shell scripting.
I'll buy that -- though personally I'd really like to see some good
coordination between AS and the shell, or other OSA scripting languages,
for those of us who don't mind tackling them, but don't like dealing
with trying to encapsulate whole scripts within a string (That feels too
much like programming and not scripting).
Michael
--
Michael Sullivan
Business Card Express of CT Thermographers to the Trade
Cheshire, CT email@hidden