9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* Re: [9fans] bug or a feature?
@ 2002-06-12 23:49 Geoff Collyer
  2002-06-13  0:07 ` Dan Cross
                   ` (2 more replies)
  0 siblings, 3 replies; 32+ messages in thread
From: Geoff Collyer @ 2002-06-12 23:49 UTC (permalink / raw)
  To: 9fans

I've always understood the utility of passing through a failed glob pattern
to be that some programs do their own globbing (as I recall, find and tar
are the two main candidates, maybe restor) and if the user forgets
to (or deliberated doesn't) quote the pattern and it doesn't match anything,
the program gets to glob it.  How useful this is may depend upon your
feelings about quoting in general.

I do think that the current behaviour is more helpful than expanding
to a null list would be.  If the pattern doesn't match, you've very likely
made a mistake.  I'd rather have ``cat ?akefile'' print

	cat: can't open ?akefile: '?akefile' directory entry not found

and exit than have it just sit there reading standard input.


^ permalink raw reply	[flat|nested] 32+ messages in thread
* Re: [9fans] bug or a feature?
@ 2002-07-27 20:30 Byron Rakitzis
  0 siblings, 0 replies; 32+ messages in thread
From: Byron Rakitzis @ 2002-07-27 20:30 UTC (permalink / raw)
  To: 9fans, presotto

>No reason to have a stack.

Ok, I see how the code generator works now!

Byron.


^ permalink raw reply	[flat|nested] 32+ messages in thread
* Re: [9fans] bug or a feature?
@ 2002-07-27 12:10 presotto
  0 siblings, 0 replies; 32+ messages in thread
From: presotto @ 2002-07-27 12:10 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 382 bytes --]

Running

if(test -e /){
	echo musthappen
	if(test -e /notthere)
		echo wonthappen
}
if not{
	echo canthappen
}

yields just 'musthappen'

You were perhaps afraid it would also print canthappen?

Looks like td sets the variable to true before the
comparison and to false on the way out of an if body
(see Xwastrue and where its emitted).  No reason to
have a stack.

[-- Attachment #2: Type: message/rfc822, Size: 2670 bytes --]

From: Byron Rakitzis <byron@rakitzis.com>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] bug or a feature?
Date: Fri, 26 Jul 2002 19:43:22 -0700
Message-ID: <200207270243.g6R2hMc04796@rakitzis.com>

>i'm happiest with
>
>        if foo
>                bar
>        if not
>                baz

Maybe someone can settle this for me.

I found "if not" an atrocity because it's not something lexically
scoped. This is apparently legal rc according to the grammar:

	if not foo
	if not bar
	if not baz

It's up to the interpreter to flag it as an error.

Granted there are many "runtime" as opposed to "parse" errors which
rc will flag for you, but it strikes me as singularly awful that the
control structure of the language should be one of those things.

Also, without thinking really hard about it, I'm not sure how
if not would work for nested ifs. Does this work the way you
would expect?

	if (foo) {
		stuff
		if (bar) {
			more stuff
		}
	}
	if not {
		!foo stuff
	}

A peek at the plan9 rc source suggests there is a global variable
called "ifnot" which makes me very, very nervous. But I don't run
plan9 at home so I can't test this code sample. What if foo is true
and bar is false?

TD was justifiably proud of rc's yacc grammar -- I suppose I felt I
was doing it one better by bringing "if .. else" under that umbrella
also.

Byron.

^ permalink raw reply	[flat|nested] 32+ messages in thread
* Re: [9fans] bug or a feature?
@ 2002-07-27  2:43 Byron Rakitzis
  0 siblings, 0 replies; 32+ messages in thread
From: Byron Rakitzis @ 2002-07-27  2:43 UTC (permalink / raw)
  To: 9fans

>i'm happiest with
>
>        if foo
>                bar
>        if not
>                baz

Maybe someone can settle this for me.

I found "if not" an atrocity because it's not something lexically
scoped. This is apparently legal rc according to the grammar:

	if not foo
	if not bar
	if not baz

It's up to the interpreter to flag it as an error.

Granted there are many "runtime" as opposed to "parse" errors which
rc will flag for you, but it strikes me as singularly awful that the
control structure of the language should be one of those things.

Also, without thinking really hard about it, I'm not sure how
if not would work for nested ifs. Does this work the way you
would expect?

	if (foo) {
		stuff
		if (bar) {
			more stuff
		}
	}
	if not {
		!foo stuff
	}

A peek at the plan9 rc source suggests there is a global variable
called "ifnot" which makes me very, very nervous. But I don't run
plan9 at home so I can't test this code sample. What if foo is true
and bar is false?

TD was justifiably proud of rc's yacc grammar -- I suppose I felt I
was doing it one better by bringing "if .. else" under that umbrella
also.

Byron.


^ permalink raw reply	[flat|nested] 32+ messages in thread
* Re: [9fans] bug or a feature?
@ 2002-06-13 23:05 Russ Cox
  2002-06-13 23:23 ` Dan Cross
  0 siblings, 1 reply; 32+ messages in thread
From: Russ Cox @ 2002-06-13 23:05 UTC (permalink / raw)
  To: 9fans

given that i can't write

	if foo
		bar
	else
		baz

i'm happiest with

	if foo
		bar
	if not
		baz

as compared with

	if foo{
		bar
	}else
		baz

or

	if foo
		bar; else
		baz

am i misunderstanding unix rc?




^ permalink raw reply	[flat|nested] 32+ messages in thread
* Re: [9fans] bug or a feature?
@ 2002-06-13 20:35 Russ Cox
  2002-06-13 20:58 ` Dan Cross
  0 siblings, 1 reply; 32+ messages in thread
From: Russ Cox @ 2002-06-13 20:35 UTC (permalink / raw)
  To: 9fans

> The rationale is explained in the following paragraphs, but apparantly,
> Unix rc has fixed that.  Indeed, the specific example given in td's
> paper is handled in a reasonable way.

requiring braces is just as much of a hack
as if not.



^ permalink raw reply	[flat|nested] 32+ messages in thread
* Re: [9fans] bug or a feature?
@ 2002-06-13  3:41 Russ Cox
  0 siblings, 0 replies; 32+ messages in thread
From: Russ Cox @ 2002-06-13  3:41 UTC (permalink / raw)
  To: 9fans

> shell globbing. Or set noglob in the shells that support it.  The fact
> that noglob exists says to me that the no-match pass-through globbing
> behaviour has been found to be problematic in the past.

no, it only means someone felt like putting it in
and was motivated enough to write the code.

russ



^ permalink raw reply	[flat|nested] 32+ messages in thread
* Re: [9fans] bug or a feature?
@ 2002-06-13  1:01 Russ Cox
  2002-06-13 17:40 ` Dan Cross
  0 siblings, 1 reply; 32+ messages in thread
From: Russ Cox @ 2002-06-13  1:01 UTC (permalink / raw)
  To: 9fans

> (And while we're at it, can we add ``else'' to Plan 9 rc?)

i was hoping someone would add if not to unix rc.



^ permalink raw reply	[flat|nested] 32+ messages in thread
[parent not found: <dmr@plan9.bell-labs.com>]
* Re: [9fans] bug or a feature?
@ 2002-06-12 19:52 andrey mirtchovski
  2002-06-12 21:57 ` Dan Cross
  0 siblings, 1 reply; 32+ messages in thread
From: andrey mirtchovski @ 2002-06-12 19:52 UTC (permalink / raw)
  To: 9fans

not to drag this any further, here's what the Rc paper has to say
about globbing (section 4):

<quote>
A pattern is replaced by a list of arguments, one for each path name
matched, except that a pattern matching no names is not replaced by
the empty list; rather it stands for itself.
</quote>

somehow it seemed to me an empty list would be the proper way.  as it
was already said -- the current behaviour is a feature, not a bug

>  > i thought that version [6th ed] of glob announced 'no match'
>  > (which csh inherits) and bourne's sh was first to
>  > pass it through to the command as-is if no names matched.
>
> This is so.  I just looked at the source.
> I think the change was generally accepted
> as an improvement, or at least neutral.
>
> 	Dennis



^ permalink raw reply	[flat|nested] 32+ messages in thread
* Re: [9fans] bug or a feature?
@ 2002-06-12  9:15 forsyth
  2002-06-13  9:29 ` Douglas A. Gwyn
  0 siblings, 1 reply; 32+ messages in thread
From: forsyth @ 2002-06-12  9:15 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 163 bytes --]

i thought that version of glob announced 'no match'
(which csh inherits) and bourne's sh was first to
pass it through to the command as-is if no names matched.

[-- Attachment #2: Type: message/rfc822, Size: 2074 bytes --]

To: <9fans@cse.psu.edu>
Subject: Re: [9fans] bug or a feature?
Date: Tue, 11 Jun 2002 15:19:08 -0600 (MDT)
Message-ID: <Pine.LNX.4.33.0206111518190.14579-100000@snaresland.acl.lanl.gov>

On Tue, 11 Jun 2002, andrey mirtchovski wrote:

> On Tue, 11 Jun 2002, rob pike, esq. wrote:
>
> > This is long-standard behavior for shells.  Feature.
>
> darn it, i didn't know this has been there since unix 6th ed...

I just showed Andrey the 9/19/73 man page for glob(VIII) and he now stands
corrected.

ron

^ permalink raw reply	[flat|nested] 32+ messages in thread
* Re: [9fans] bug or a feature?
@ 2002-06-11 15:32 Russ Cox
  0 siblings, 0 replies; 32+ messages in thread
From: Russ Cox @ 2002-06-11 15:32 UTC (permalink / raw)
  To: 9fans

> this causes cpurc to fail on diskless machines.

termrc says

	for(disk in /dev/sd??) {
		if(test -f $disk/data && test -f $disk/ctl)
			disk/fdisk -p $disk/data >$disk/ctl >[2]/dev/null
		for(part in $disk/plan9*)
			if(test -f $part)
				disk/prep -p $part >$disk/ctl >[2]/dev/null
	}

cpurc doesn't mention disks.



^ permalink raw reply	[flat|nested] 32+ messages in thread
* Re: [9fans] bug or a feature?
@ 2002-06-11 15:29 rob pike, esq.
  2002-06-11 21:05 ` andrey mirtchovski
  2002-06-12  8:53 ` Douglas A. Gwyn
  0 siblings, 2 replies; 32+ messages in thread
From: rob pike, esq. @ 2002-06-11 15:29 UTC (permalink / raw)
  To: 9fans

> shouldn't rc return an empty list if the glob matching does not
> succeed?  currently it returns the actual string it attempted to glob,

This is long-standard behavior for shells.  Feature.

-rob



^ permalink raw reply	[flat|nested] 32+ messages in thread
* Re: [9fans] bug or a feature?
@ 2002-06-11 15:26 andrey mirtchovski
  0 siblings, 0 replies; 32+ messages in thread
From: andrey mirtchovski @ 2002-06-11 15:26 UTC (permalink / raw)
  To: 9fans

> cpurc doesn't mention disks.

some locally modified cpurc which includes crud for our local network.
my fault.



^ permalink raw reply	[flat|nested] 32+ messages in thread
* [9fans] bug or a feature?
@ 2002-06-11 15:14 andrey mirtchovski
  0 siblings, 0 replies; 32+ messages in thread
From: andrey mirtchovski @ 2002-06-11 15:14 UTC (permalink / raw)
  To: 9fans

shouldn't rc return an empty list if the glob matching does not
succeed?  currently it returns the actual string it attempted to glob,
as in:

p9% for(i in /dev/sd??) echo $i
/dev/sdC0
/dev/sdD0
p9% for(i in /dev/sd?) echo $i
/dev/sd?
p9%

this causes cpurc to fail on diskless machines.

proposed behaviour:

p9% for(i in /dev/sd??) echo $i
/dev/sdC0
/dev/sdD0
p9% for(i in /dev/sd?) echo $i
p9% for(i in '/dev/sd?') echo $i
/dev/sd?
p9%



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

end of thread, other threads:[~2002-07-27 20:30 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-12 23:49 [9fans] bug or a feature? Geoff Collyer
2002-06-13  0:07 ` Dan Cross
2002-06-13  0:31 ` Pavel Mihaylov
2002-06-13  2:29 ` Lyndon Nerenberg
  -- strict thread matches above, loose matches on Subject: below --
2002-07-27 20:30 Byron Rakitzis
2002-07-27 12:10 presotto
2002-07-27  2:43 Byron Rakitzis
2002-06-13 23:05 Russ Cox
2002-06-13 23:23 ` Dan Cross
2002-06-13 20:35 Russ Cox
2002-06-13 20:58 ` Dan Cross
2002-06-13 21:34   ` Tharaneedharan Vilwanathan
2002-06-13  3:41 Russ Cox
2002-06-13  1:01 Russ Cox
2002-06-13 17:40 ` Dan Cross
     [not found] <dmr@plan9.bell-labs.com>
2002-06-12 19:57 ` Dennis Ritchie
2002-06-12 20:16   ` Scott Schwartz
2002-06-12 19:52 andrey mirtchovski
2002-06-12 21:57 ` Dan Cross
2002-06-12 22:53   ` Lyndon Nerenberg
2002-06-14  8:45     ` Douglas A. Gwyn
2002-06-14 16:23       ` Lyndon Nerenberg
2002-06-12  9:15 forsyth
2002-06-13  9:29 ` Douglas A. Gwyn
2002-06-11 15:32 Russ Cox
2002-06-11 15:29 rob pike, esq.
2002-06-11 21:05 ` andrey mirtchovski
2002-06-11 21:19   ` Ronald G Minnich
2002-06-12  5:17     ` Lucio De Re
2002-06-12  8:53 ` Douglas A. Gwyn
2002-06-11 15:26 andrey mirtchovski
2002-06-11 15:14 andrey mirtchovski

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