rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
* status of `{} commands
@ 1991-09-28  3:24 Chris Siebenmann
  0 siblings, 0 replies; 2+ messages in thread
From: Chris Siebenmann @ 1991-09-28  3:24 UTC (permalink / raw)
  To: rc

could rc make $status after a `{} command the status of the last command
in the backquotes, especially in the context of 'var=`{command(s)}'? It
would make unnecessary a number of annoying hacks, like:
	var=`` $nl {line; echo $status}
	if (! ~ $#var 2 || ! ~ $var(2) 0)
		break;	# EOF or error
	var=`{echo $var(1)}
for a workable first pass at read that notices EOF.

	- cks


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

* Re:  status of `{} commands
@ 1991-09-28  4:43 Byron Rakitzis
  0 siblings, 0 replies; 2+ messages in thread
From: Byron Rakitzis @ 1991-09-28  4:43 UTC (permalink / raw)
  To: rc

Unfortunately, `{} is not a command, it is a construct that exapands to a list.
Let's leave it that way.

The only time I can see you being interested in the exit status of a command
in backquotes is when assigning variables, otherwise the very meaning of
$status becomes distorted. i.e.,

	echo `{/bin/false}

should set status to true, in my opinion. Allowing ` to set $status would
clutter the semantics of `, imho.

I'm not sure what to do in the case of assignments. Would it not be possible
to write a function which takes a command and a variable name as arguments
and performs the assignment while overriding $status?

e.g.,

	fn assigncc {
		tmp = `` $nl {eval $2; echo $status}
		if (~ $#tmp 2 && ~ $tmp(2) 0) {
			$1 = `{echo $tmp(1)}
		} else {
			return 1
		}
	}

to be used as

	assigncc foo 'echo hi'

I will agree that this option would be more feasible if you could pass
pieces of rc code as arguments. The eval and the quoting of the command
to be executed is definitely problematic.


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

end of thread, other threads:[~1991-09-28  4:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1991-09-28  3:24 status of `{} commands Chris Siebenmann
1991-09-28  4:43 Byron Rakitzis

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).