From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from cortex.physiol.su.oz.au ([129.78.139.131]) by hawkwind.utcs.toronto.edu with SMTP id <2221>; Sun, 12 Jul 1992 19:02:47 -0400 Received: by cortex.physiol.su.oz.au (5.57/Ultrix3.0-C) id AA01819; Mon, 13 Jul 92 09:02:31 +1000 From: John (_You_ hide, they seek.) Mackin Date: Sun, 12 Jul 1992 18:53:55 -0400 To: The rc Mailing List Subject: Re: backquote status? In-Reply-To: <92Jul11.201318edt.2604@groucho.cs.psu.edu> Message-Id: <199207130853.1648.rc.babap@physiol.su.oz.au> X-Face: 39seV7n\`#asqOFdx#oj/Uz*lseO_1n9n7rQS;~ve\e`&Z},nU1+>0X^>mg&M.^X$[ez>{F k5[Ah<7xBWF-@-ru?& @4K4-b`ydd^`(n%Z{ Is there any way to retrieve the status from a backquote command? It seems that assignments (like x=`false) set status=0. Is that a feature? We really need to put together an rc FAQ. I'll volunteer to do it, although I won't be able to start until I get myself properly established in my new job, which will take some weeks. This one has been discussed on the list at least twice already. If you look at the grammar, an assignment is a command. $status reflects the status of the last command. The "false" failed, but the assignment succeeded, so $status is correctly zero. Yes, it is a little surprising. If you want the status from the backquoted command, you can do the usual sh-style trick of putting it on a suitable fd, something like: fred = ` { false; echo $status >[1=2] } That can be elaborated as needed. In some cases, the -e command line option can be used to advantage. Also, rc will print an error message if a backquoted command exits on a signal (Byron once said he wasn't sure if that was a good feature or not -- personally I don't mind it). OK, John.