rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
From: Tim Goodwin <tjg@star.le.ac.uk>
To: rc@hawkwind.utcs.toronto.edu
Subject: Re: New rc snapshot, includes "the equals hack"
Date: Thu, 17 Aug 2000 05:49:25 -0500	[thread overview]
Message-ID: <qUAAADy1mzlmIwAA@ltsun0.star.le.ac.uk> (raw)
In-Reply-To: <20000815133234Z3021-8597+4@cesium.clock.org> <20000815215120.111.qmail@pantransit.reptiles.org>

> Maybe I'm a bit of a crank, but I think for scripting work,
> the "equals hack" really doesn't buy much;

Agreed.

> 	: sean(rc) ; echo foo&a
> 	12978
>       a not found
>       foo

That's not really a valid analogy: `echo a&b' has a perfectly good
meaning (even if it's probably not the one you wanted).  This contrasts
with `echo a=b' for which rc just spits back `syntax error', even though
it has an unambiguous, and useful, meaning.

> Putting the Q= at the end results in a syntax error due to the trailing
> implicit caret, and you'll run into this problem with a trailing =
> anywhere.  I'd rather have a fix that works completely, or just go on
> quoting things as I have been.

And, as Byron pointed out, a doubled equals is also a syntax error.

Both of these can be fixed by adding this production to the grammar.

    word : word '='

This introduces a large number of shift/reduce conflicts.  My immediate
reaction is that they should all be benign (since yacc always shifts, so
it will only use this production when there's no valid longer parse),
but I'd have to think about it a bit longer to really convince myself.

Under this regime, the only odd special case I can find is `a==b', which
remains a syntax error.

> Sorry to be crank-like again, but while the rc + 'equals hack' can run
> old rc scripts just fine, anyone who writes any script without quoting
> an argument containing '=' will find it unportable to an 'unhacked' rc.

Yes, that is a worry.  One bletcherous possibility would be to allow the
equals hack only when we're interactive.

It's still only a two line patch, but they're starting to be rather long
lines.  :-)

Time for a coffee, and I'll see if I can come up with anything better...

Tim.

--- parse.y	1998/07/10 13:41:38	1.2
+++ parse.y	2000/08/17 09:20:45
@@ -127,6 +127,8 @@
 	| keyword			{ $$ = mk(nWord,$1, NULL); }
 
 word	: sword
+	| word '='			{ if (interactive) { $$ = mk(nConcat,$1,mk(nWord,"=",NULL)); } else { yyerror("syntax error"); YYERROR; } }
+	| word '=' sword		{ if (interactive) { $$ = mk(nConcat,$1,mk(nConcat,mk(nWord,"=",NULL),$3)); } else { yyerror("syntax error"); YYERROR; } }
 	| word '^' sword		{ $$ = mk(nConcat,$1,$3); }
 
 comword	: '$' sword			{ $$ = mk(nVar,$2); }


  parent reply	other threads:[~2000-08-18 22:10 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-08-15 14:32 smd
2000-08-15 22:51 ` Smarasderagd
2000-08-17  3:53   ` Decklin Foster
2000-08-21 23:21     ` Chris Siebenmann
2000-08-22 11:51       ` Carlo Strozzi
2000-08-17 10:49   ` Tim Goodwin [this message]
  -- strict thread matches above, loose matches on Subject: below --
2000-08-23  1:03 Byron Rakitzis
2000-08-22  0:28 Byron Rakitzis
2000-08-22 23:23 ` Chris Siebenmann
2000-08-18 21:14 Bengt Kleberg
2000-08-15 20:25 smd
2000-08-15  7:28 Byron Rakitzis
2000-08-15  6:41 Byron Rakitzis
2000-08-11 14:01 Tim Goodwin
2000-08-15  2:21 ` Paul Haahr
2000-08-15  4:21 ` Gary Carvell
2000-08-15 14:52 ` Mark K. Gardner

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=qUAAADy1mzlmIwAA@ltsun0.star.le.ac.uk \
    --to=tjg@star.le.ac.uk \
    --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).