[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problems with ~ and ~~



> It's a fairly messy distinction.  I'm very unhappy with it.  If Unix
> didn't have exit statuses, it would probably never have happened.
> Instead, I generalized exit statuses in a way they shouldn't have been.

i thought about this quite hard when deciding what to do about this
issue in my es-reminiscent shell for inferno (named, unimaginatively
"sh").

eventually i decided that exit status and return value are two quite
different things, one being essentially true/false, and the other
multi-valued.

unlike es, i wasn't limited by the strict exec/wait boundary, so i
implemented two classes of runnable shell objects, commands, and
"substitution operators" (a terrible name).  commands are run as
usual; substitution operators look like braced commands run with the $
operator.

e.g.
	x = ${split e 'hello there'}

there is no "split" command - names invoked by the ${} operator are
taken from a different namespace.

this means that normal commands retain their true/false nature, while
substitution operators (which are dynamically definable) don't try to
stretch the definition of "true" and "false".

does
	if {%split x 'hello there'} {
		...
	}
really have any useful meaning?

it's quite nice being able to use the "split" unambiguously for both
the above:

	x = ${split e 'hello there'}

and also:

	split -1000 somefile

(the unix-style command).

if anyone's interested, this shell takes the one core es concept
(braced blocks as values) and tries to push it as far as it'll go,
while keeping the core syntax to a bare minimum.  it manages to be an
extensible shell, not because you can override stuff underneath the
syntactic sugar, as with es, but because almost all of what would be
considered "code syntax" in most shells is implemented externally
(e.g.  if, while, fn, etc, etc) and hence can be redefined or
reinvented.

it allows the core shell to be fairly small (2480 lines total, a 40K
binary) but more powerful than most.

if you are interested, there's a wee paper on it at:

	http://www.vitanuova.com/inferno/papers/sh.html

and the documentation at:

	http://www.vitanuova.com/inferno/man/1/sh.html

and if you're using Internet Explorer under Windows
and can't be bothered with the 14MB free download,
you can even have a play with it in your web browser!

	http://www.vitanuova.com/inferno/pi/shell/index.html

now i'll see whether i can get my conversation with the SMTP
server correct this time (the local SMTP client got a bounce
saying "please use your fully qualified real domain name",
and since i don't control it, i guess manual telnet is the only way!)

  cheers,
    rog. (rog@vitanuova.com a.k.a. rog@ohm.york.ac.uk, in case
	this post also comes through with an odd address!)