Re: To err on the exit code of the FIRST cmd of a piped do shell script
Re: To err on the exit code of the FIRST cmd of a piped do shell script
- Subject: Re: To err on the exit code of the FIRST cmd of a piped do shell script
- From: Harald E Brandt <email@hidden>
- Date: Tue, 9 Dec 2003 14:11:17 +0100
+--> Christopher Nebel wrote 03-12-08:
On Dec 8, 2003, at 6:26 AM, Harald E Brandt wrote:
Consider this toy example:
do shell script "curl badURL | vis"
Without the pipe, the thing would error with error code 6 - very
easy to trap with a try block. With the pipe, however, it does not
error at all! That's because the exit status is the exit status of
the last command specified in the pipeline - basic shell behavior.
But of course I want that line to error since curl is erroring. How
to do that?
Try this:
do shell script "curl badURL | vis; exit ${PIPESTATUS[0]}"
+-
That's just sooo nice! As clean as it can get!
+--
See PIPESTATUS in the sh man page for details.
+--
But.... there is no PIPESTATUS in man sh!? At least not in the man
pages of Jaguar. And not in csh or tcsh either. But I found it in the
man page of bash!
--heb
_______________________________________________
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.