rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
* backquote status?
@ 1992-07-12  0:13 Scott Schwartz
  1992-07-12 22:53 ` John Mackin
  0 siblings, 1 reply; 2+ messages in thread
From: Scott Schwartz @ 1992-07-12  0:13 UTC (permalink / raw)
  To: rc

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?

-- Scott


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: backquote status?
  1992-07-12  0:13 backquote status? Scott Schwartz
@ 1992-07-12 22:53 ` John Mackin
  0 siblings, 0 replies; 2+ messages in thread
From: John Mackin @ 1992-07-12 22:53 UTC (permalink / raw)
  To: The rc Mailing List

    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.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1992-07-12 23:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1992-07-12  0:13 backquote status? Scott Schwartz
1992-07-12 22:53 ` John Mackin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).