From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from apollo.le.ac.uk ([143.210.16.125]) by hawkwind.utcs.utoronto.ca with SMTP id <44254>; Fri, 18 Aug 2000 17:10:37 -0500 Received: from happy.star.le.ac.uk ([143.210.36.58]) by apollo.le.ac.uk with smtp (Exim 3.13 #2) id 13PMIi-0002R1-00 for rc@hawkwind.utcs.toronto.edu; Thu, 17 Aug 2000 10:49:28 +0100 Received: (qmail 8301 invoked from network); 17 Aug 2000 09:49:49 -0000 Received: from ltpcg.star.le.ac.uk (tjg@143.210.36.203) by happy.star.le.ac.uk with SMTP; 17 Aug 2000 09:49:49 -0000 To: rc@hawkwind.utcs.toronto.edu Subject: Re: New rc snapshot, includes "the equals hack" In-Reply-To: <20000815133234Z3021-8597+4@cesium.clock.org> <20000815215120.111.qmail@pantransit.reptiles.org> Date: Thu, 17 Aug 2000 05:49:25 -0500 From: Tim Goodwin Message-ID: > 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); }