rc-list - mailing list for the rc(1) shell
 help / color / mirror / Atom feed
* Re: New rc snapshot, includes "the equals hack"
@ 2000-08-15 20:25 smd
  0 siblings, 0 replies; 17+ messages in thread
From: smd @ 2000-08-15 20:25 UTC (permalink / raw)
  To: rc


| YES! This fixes one of the few remaining things in rc that has caused
| me grief and although I have gotten used to quoting the arguments to
| FSF tools, e.g., autoconfig generated configure scripts, I would
| prefer not to do it. By all means keep it.

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.

Can one even _determine_ at run time that the equals hack is present,
other than by causing an error? 

	Sean.


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

* Re: New rc snapshot, includes "the equals hack"
@ 2000-08-23  1:03 Byron Rakitzis
  0 siblings, 0 replies; 17+ messages in thread
From: Byron Rakitzis @ 2000-08-23  1:03 UTC (permalink / raw)
  To: cks, rc

>I fear that the current '=' hack is likely to deliver a fair amount of
>the latter.

I'm sorry, I wasn't arguing in favor of the equals hack, merely *some*
equals hack to do the right thing. Of all your examples:

	; echo =b

is the most troubling since sh does the visually obvious thing, but
rc allows spaces between the '=' and its operands. That can't change
without breaking old scripts.

Byron.


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

* Re: New rc snapshot, includes "the equals hack"
  2000-08-22  0:28 Byron Rakitzis
@ 2000-08-22 23:23 ` Chris Siebenmann
  0 siblings, 0 replies; 17+ messages in thread
From: Chris Siebenmann @ 2000-08-22 23:23 UTC (permalink / raw)
  To: rc

| Well, the principle of "free carets" already establishes that there
| can be some counterintuitive parsing:

 The difference to me is that 'free carets' doesn't move things around;
it merely logically connects things that are already visually connected.
This lets it work intuitively and do what the user expects. By contrast,
the '=' hack does move things around, and I think that's the problem.
It's also incomplete and surprising.

 So we have:
	; echo a = b
	a=b
	; echo a= b
	a=b
	; echo a =b
	a=b
Bonus unpleasant surprise:
	; echo =b
	;
And we haven't even gotten away from needing quotes in some situations:
	; echo a==b
	syntax error
	; echo =
	syntax error

 I think that rearranging what the user types is jarringly out of place
and counterintuitive.

| I think there is enough historical precedent about the use of unquoted
| ='s in shells that to be forced quote them is a truly annoying bug.

 I would rather be annoyed periodically than (unpleasantly) surprised.
I fear that the current '=' hack is likely to deliver a fair amount of
the latter.

	- cks


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

* Re: New rc snapshot, includes "the equals hack"
  2000-08-21 23:21     ` Chris Siebenmann
@ 2000-08-22 11:51       ` Carlo Strozzi
  0 siblings, 0 replies; 17+ messages in thread
From: Carlo Strozzi @ 2000-08-22 11:51 UTC (permalink / raw)
  To: rc

On Mon, Aug 21, 2000 at 06:21:14PM -0500, Chris Siebenmann wrote:
| | It just feels too sneaky and obscure to me. Part of the appeal of rc
| | is it's clear syntax; there aren't a lot of exceptions like this one.
| 
|  Having read the messages to date and thought about the issue, I think
| that I agree with this. I prefer an rc where the rule I have to remember
| is 'quote ='s or get syntax errors', not '= will gobble the arguments
| on either side of it on a command line into one word' (or whatever the
| exact rule is). And slipups are far more evident and less mysterious
| with the first rule: I get a syntax error, which I can easily fix.

I personally share the same view.

bye	--carlo
-- 
I can read MIME or uuencoded e-mail attachments in PDF, Postscript, HTML,
RTF or text formats. Please do not send Word, Excel or PowerPoint files. 



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

* Re: New rc snapshot, includes "the equals hack"
@ 2000-08-22  0:28 Byron Rakitzis
  2000-08-22 23:23 ` Chris Siebenmann
  0 siblings, 1 reply; 17+ messages in thread
From: Byron Rakitzis @ 2000-08-22  0:28 UTC (permalink / raw)
  To: cks, rc

>  Having read the messages to date and thought about the issue, I think
> that I agree with this. I prefer an rc where the rule I have to remember
> is 'quote ='s or get syntax errors', not '= will gobble the arguments
> on either side of it on a command line into one word' (or whatever the
> exact rule is). And slipups are far more evident and less mysterious
> with the first rule: I get a syntax error, which I can easily fix.

Well, the principle of "free carets" already establishes that there
can be some counterintuitive parsing:

	; ~a
	; a~
	a~ not found
	;

I guess the real problem is that = is an infix operator, and what's more
multiple local assignments are allowed:

	a=foo b=bar cmd

This more than anything bollixed up any attempt to do the Right Thing
with yacc alone when I last puzzled over this (which was, mind you almost
10 years ago!).

And what is the right thing? I guess it's easy to say in English: if '='
does not appear in an assignment it should be subject to free careting.

This would be trivial to do in a recursive-descent parser which could
communicate with the lexer, I'm unsure about how to accomplish it
with yacc.

I think there is enough historical precedent about the use of unquoted
='s in shells that to be forced quote them is a truly annoying bug.

Byron.


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

* Re: New rc snapshot, includes "the equals hack"
  2000-08-17  3:53   ` Decklin Foster
@ 2000-08-21 23:21     ` Chris Siebenmann
  2000-08-22 11:51       ` Carlo Strozzi
  0 siblings, 1 reply; 17+ messages in thread
From: Chris Siebenmann @ 2000-08-21 23:21 UTC (permalink / raw)
  To: rc

| It just feels too sneaky and obscure to me. Part of the appeal of rc
| is it's clear syntax; there aren't a lot of exceptions like this one.

 Having read the messages to date and thought about the issue, I think
that I agree with this. I prefer an rc where the rule I have to remember
is 'quote ='s or get syntax errors', not '= will gobble the arguments
on either side of it on a command line into one word' (or whatever the
exact rule is). And slipups are far more evident and less mysterious
with the first rule: I get a syntax error, which I can easily fix.

	- cks


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

* Re: New rc snapshot, includes "the equals hack"
@ 2000-08-18 21:14 Bengt Kleberg
  0 siblings, 0 replies; 17+ messages in thread
From: Bengt Kleberg @ 2000-08-18 21:14 UTC (permalink / raw)
  To: rc, tjg

> permits `=' to appear, unquoted, outside assignments.

Could this be made into a compile time switch?
Ie, I do not want it, but I fully understand if others do.


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

* Re: New rc snapshot, includes "the equals hack"
  2000-08-15 22:51 ` Smarasderagd
  2000-08-17  3:53   ` Decklin Foster
@ 2000-08-17 10:49   ` Tim Goodwin
  1 sibling, 0 replies; 17+ messages in thread
From: Tim Goodwin @ 2000-08-17 10:49 UTC (permalink / raw)
  To: rc

> 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); }


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

* Re: New rc snapshot, includes "the equals hack"
  2000-08-15 22:51 ` Smarasderagd
@ 2000-08-17  3:53   ` Decklin Foster
  2000-08-21 23:21     ` Chris Siebenmann
  2000-08-17 10:49   ` Tim Goodwin
  1 sibling, 1 reply; 17+ messages in thread
From: Decklin Foster @ 2000-08-17  3:53 UTC (permalink / raw)
  To: Smarasderagd; +Cc: rc

Smarasderagd writes:

> make Q= target

There is always make Q='', which also fixes the =-at-end-of-line
problem. I'm somewhat ambivalent about offering workarounds, though,
because I agree with what you have written below:

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

It just feels too sneaky and obscure to me. Part of the appeal of rc
is it's clear syntax; there aren't a lot of exceptions like this one.

P.S. Just a heads up for the group: I have taken over maintainership
of rc for Debian; feel free to contact me about any packaging issues.

-- 
There is no TRUTH. There is no REALITY. There is no CONSISTENCY. There
are no ABSOLUTE STATEMENTS. I'm very probably wrong. -- BSD fortune(6)


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

* Re: New rc snapshot, includes "the equals hack"
@ 2000-08-15 22:51 ` Smarasderagd
  2000-08-17  3:53   ` Decklin Foster
  2000-08-17 10:49   ` Tim Goodwin
  0 siblings, 2 replies; 17+ messages in thread
From: Smarasderagd @ 2000-08-15 22:51 UTC (permalink / raw)
  To: rc, tjg

Tim Goodwin <tjg@star.le.ac.uk> writes:
>A new, and possibly controversial, rc development snapshot is available
>from the usual place.
>
>    http://www.star.le.ac.uk/~tjg/rc/snap/rc-1.6s20000811.tar.gz
>
>There are a few minor bug fixes, and the addition of the `-I' flag
>from the Plan9 rc (the opposite of `-i': this shell is definitely not
>interactive).  See the full list of changes since the last beta at the
>end of this message.
>
>In addition, this snapshot includes a cunning patch by Thomas Nordin
>that permits `=' to appear, unquoted, outside assignments.  For ease of
>reference, I'm calling this "the equals hack", where the word "hack" is
>not intended to have any pejorative connotations...
>
>The equals hack, which in fact was just a one line addition to the
>grammar, effectively makes `=' stand for `^'='^' (when it's not an
>assignment).  The slightly surprising feature of this is that `='
>swallows whitespace around it.
>
>    ; echo a = b
>    a=b
>
>Apart from that, everything works as you would expect.

Well, I suppose expr's '=' operator isn't much of an issue, and the '>='
and '<=' operators need to be quoted anyway (I think.)  Make runs with
null assignments to makefile variables would still not work right, though.

make Q= target

turns into

make Q=target

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.


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

* Re: New rc snapshot, includes "the equals hack"
  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
  2 siblings, 0 replies; 17+ messages in thread
From: Mark K. Gardner @ 2000-08-15 14:52 UTC (permalink / raw)
  To: rc; +Cc: Tim Goodwin

On Friday, 11 Aug 2000 Tim Goodwin said:
> What do you think?  Should the equals hack stay?

YES! This fixes one of the few remaining things in rc that has caused
me grief and although I have gotten used to quoting the arguments to
FSF tools, e.g., autoconfig generated configure scripts, I would
prefer not to do it. By all means keep it.

Mark

-- 
Mark K. Gardner
RADIANT Team
Network Engineering, CIC-5
Los Alamos National Laboratory
P.O. Box 1663, M.S. D451
Los Alamos, NM 87545
Email: mkg@lanl.gov
Phone: 1-505-665-4953
-- 


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

* Re: New rc snapshot, includes "the equals hack"
@ 2000-08-15 14:32 smd
  2000-08-15 22:51 ` Smarasderagd
  0 siblings, 1 reply; 17+ messages in thread
From: smd @ 2000-08-15 14:32 UTC (permalink / raw)
  To: rc


Maybe I'm a bit of a crank, but I think for scripting work,
the "equals hack" really doesn't buy much; the only time I 
even ponder it is when I am doing interactive work and forget
that "arguments containing special characters must be quoted".

Although I know that dd, make, and some GNU utilities like
arguments which contain one of rc's special characters, and
this can be frustrating if one forgets, I don't see why we
should necessarily have:

	: sean(rc) ; echo foo=a
	foo=a

but

	: sean(rc) ; echo foo^a
	fooa
	: sean(rc) ; echo foo&a
	12978
        a not found
	foo
	: sean(rc) ; echo foo;a
	foo
	a not found
	: sean(rc) ; echo foo$a
	foo

and so forth.    One of the neat things about rc is that there
are few syntactic surprises; I think a rule that says "quote your arguments"
and especially "arguments with special characters MUST be quoted" is
consistent.

	Sean. 


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

* Re: New rc snapshot, includes "the equals hack"
@ 2000-08-15  7:28 Byron Rakitzis
  0 siblings, 0 replies; 17+ messages in thread
From: Byron Rakitzis @ 2000-08-15  7:28 UTC (permalink / raw)
  To: gcarvell, tjg; +Cc: rc

>Yes! Yes! Yes! Keep it!!!

I just read my note to the list, and it seems very equivocal. I just
wanted to say, even in its present form the equals hack is a big
improvement over what's there right now. It's just that I've struggled
with this problem before so I'm trying to see it in the context of the
other efforts. In a perfect world I would love to see an equals hack
which does the Right Thing.

Byron.


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

* Re: New rc snapshot, includes "the equals hack"
@ 2000-08-15  6:41 Byron Rakitzis
  0 siblings, 0 replies; 17+ messages in thread
From: Byron Rakitzis @ 2000-08-15  6:41 UTC (permalink / raw)
  To: rc, tjg

Paul and I sought an "equals hack" back in 1992 or so but for some reason
we were unable to come up with something clean.

The "equals hack" solves the "dd bug" and the "make bug" which are the two
most frequent uses of equals sign on the command line, at least for me.

As for the unexpected gluing of = to its neighbors, I suppose that is
the lesser evil -- rc already has this notion of "free carets" so it's
a bug which at least makes sense in that context.

I think what prevented me from doing this a while ago is that I was
trying to fix lexing of '=' in the lexical analyzer: this would have made
the scanning of '=' context-sensitive and it would avoid the unexpected
behavior of free-careting '=' to its neighbors. But, after some effort
I wasn't able to get this to work in a satisfactory way. It certainly
wasn't a one-line fix.

I don't know, what do other people think? In practical use, I can't see
that the equals hack is a bad thing.

You could always separate out the equals by quoting:

	echo a '=' b

Of course, the equals hack also has some non-obvious side-effects:

; echo a=  
syntax error
; echo a==
syntax error
; echo a==b
syntax error
; 

One thing is for sure, it's a hack...

Byron.


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

* Re: New rc snapshot, includes "the equals hack"
  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
  2 siblings, 0 replies; 17+ messages in thread
From: Gary Carvell @ 2000-08-15  4:21 UTC (permalink / raw)
  To: Tim Goodwin; +Cc: rc

On Fri, Aug 11, 2000 at 09:01:32AM -0500, Tim Goodwin wrote:
> What do you think?  Should the equals hack stay?
> 
> Tim.

Yes! Yes! Yes! Keep it!!! (Sorry :-) I will be downloading
the snapshot ASAP to try this out. Your two examples, dd and
configure, are in fact the only times I ever drop into sh -
just can't stand typing all those quotes for all the command
line arguments. It may be a tiny hack, but a definite big
usability win.

Gary

-- 
Gary Carvell
gcarvell@wirefire.com


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

* Re: New rc snapshot, includes "the equals hack"
  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
  2 siblings, 0 replies; 17+ messages in thread
From: Paul Haahr @ 2000-08-15  2:21 UTC (permalink / raw)
  To: Tim Goodwin; +Cc: rc

> What do you think?  Should the equals hack stay?

Yes.  (I'll try to add it to es in the near future.)

Back when Byron wrote rc (and I wrote es) there was nary a command which
took '=' as its argument.  dd was the most popular, if I remember.  But,
these days, all sorts of commands take long options with = instead of
spaces as the argument separator.

Blame it on GNU.  :-)

--p


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

* New rc snapshot, includes "the equals hack"
@ 2000-08-11 14:01 Tim Goodwin
  2000-08-15  2:21 ` Paul Haahr
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Tim Goodwin @ 2000-08-11 14:01 UTC (permalink / raw)
  To: rc

A new, and possibly controversial, rc development snapshot is available
from the usual place.

    http://www.star.le.ac.uk/~tjg/rc/snap/rc-1.6s20000811.tar.gz

There are a few minor bug fixes, and the addition of the `-I' flag
from the Plan9 rc (the opposite of `-i': this shell is definitely not
interactive).  See the full list of changes since the last beta at the
end of this message.

In addition, this snapshot includes a cunning patch by Thomas Nordin
that permits `=' to appear, unquoted, outside assignments.  For ease of
reference, I'm calling this "the equals hack", where the word "hack" is
not intended to have any pejorative connotations...

The equals hack, which in fact was just a one line addition to the
grammar, effectively makes `=' stand for `^'='^' (when it's not an
assignment).  The slightly surprising feature of this is that `='
swallows whitespace around it.

    ; echo a = b
    a=b

Apart from that, everything works as you would expect.

    ; dd if=/etc/group |wc
    1+1 records in
    1+1 records out
         44      44     780

    ; sh configure --prefix=/local
    [...]

    ; a=b=c b=c echo $a $b
    b=c c

(All these were previously syntax errors.  The equals hack doesn't
change the meaning of anything that was previously legal.)

What do you think?  Should the equals hack stay?

Tim.


2000-04-19

  Bug: isatty() tests in input.c are relevant to any fd, not just 0.
  Now `. -i /dev/tty' works right.

  Bug: fn sigexit wasn't always cleared in child shells.

  Bug: `~ () '*'' dumped core.

2000-05-25

  Portability: need special runes for read() returning EIO under job
  control systems.

2000-06-20

  Feature: add `-I' flag (definitively not interactive) for
  compatibility with Plan 9 rc.

2000-07-27

  Feature: the "equals hack".


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

end of thread, other threads:[~2000-08-23 17:25 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-08-15 20:25 New rc snapshot, includes "the equals hack" smd
  -- 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 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
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

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