rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
From: John (_You_ hide, they seek.) Mackin <john@physiol.su.oz.au>
To: The rc Mailing List <rc@hawkwind.utcs.toronto.edu>
Subject: Re: backquote status?
Date: Sun, 12 Jul 1992 18:53:55 -0400	[thread overview]
Message-ID: <199207130853.1648.rc.babap@physiol.su.oz.au> (raw)
In-Reply-To: <92Jul11.201318edt.2604@groucho.cs.psu.edu>

    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.


      reply	other threads:[~1992-07-12 23:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1992-07-12  0:13 Scott Schwartz
1992-07-12 22:53 ` John Mackin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199207130853.1648.rc.babap@physiol.su.oz.au \
    --to=john@physiol.su.oz.au \
    --cc=rc@hawkwind.utcs.toronto.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).