do shell script gotcha
do shell script gotcha
- Subject: do shell script gotcha
- From: Donald Hall <email@hidden>
- Date: Tue, 25 Feb 2003 00:33:19 -0700
I recently discovered a change in AppleScript behavior in Jaguar that
I didn't see in the Release Notes for AS 1.9.
do shell script "ls myFile" returns an empty result if myFile can't
be found. In AS 1.8 it returns something like "No such file or
directory myFile". I was using the presence or absence of "No" in the
result to determine if the file was there or not. Of course this
broke in Jaguar, causing my script to give an "unexpected result". To
cover both 10.1 and 10.2, I now use:
set shellResult to do shell script "ls myFile"
if shellResult is "" or (offset of "No" in shellResult is not equal
to 0) then -- file not found
Perhaps you already knew this, but if not, it might save you the time
I spent figuring out what was wrong with my script on 10.2!
Don
--
Donald S. Hall, Ph.D.
Apps & More Software Design, Inc.
email@hidden
http://www.appsandmore.com
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.