Re: do shell script gotcha
Re: do shell script gotcha
- Subject: Re: do shell script gotcha
- From: "Michael P. Wilson" <email@hidden>
- Date: Tue, 25 Feb 2003 02:42:33 -0500
Excuse my massive ignorance, but here's a shot in the dark:
Does ls return a nonzero exit code when there's no result (man page
doesn't say) and did AS 1.9 start picking up exit codes?
On Tuesday, Feb 25, 2003, at 02:33 America/New_York, Donald Hall wrote:
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.
-
"Thus nature has no love for solitude, and always leans, as it were, on
some support; and the sweetest support is found in the most intimate
friendship." - Cicero
_______________________________________________
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.