Re: Getting values returned by Unix command-line programs
Re: Getting values returned by Unix command-line programs
- Subject: Re: Getting values returned by Unix command-line programs
- From: Christopher Nebel <email@hidden>
- Date: Thu, 18 Mar 2004 01:52:24 -0800
On Mar 17, 2004, at 11:52 PM, steve harley wrote:
a nonzero return status from the shell command throws an error, so you
could use a try block ... i had just mentioned in another thread that
it's unfortunate that do shell script works this way. i think
non-zero return status from shell commands is not semantically
equivalent to AppleScript's notion of an error.
In fact, for almost all commands, non-zero status means something went
wrong -- no such file, bogus arguments, etc. test(1) is the exception,
not the rule. Equivalents to "do shell script" in other languages all
return stdout as their result, same as "do shell script" does -- what
are you suggesting?
because of that i'd lean toward something like this instead:
set retval to do shell script "if myprog ; then echo 0 ; else echo 1
; fi
Other equivalents include
do shell script "myprog && echo 0 || echo 1"
and my personal favorite,
do shell script "myprog; echo $?"
--Chris Nebel
AppleScript Engineering
_______________________________________________
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.