9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] awk bug
@ 2010-04-19 16:33 erik quanstrom
  0 siblings, 0 replies; 6+ messages in thread
From: erik quanstrom @ 2010-04-19 16:33 UTC (permalink / raw)
  To: 9fans

sorry i left out a part:

minooka; awk 'BEGIN {OFMT="%.0f"; print 17.23}'
17
minooka; /n/sources/plan9/386/bin/awk 'BEGIN {OFMT="%.0f"; print 17.23}'
17.23

- erik



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

* Re: [9fans] awk bug
  2003-09-15 11:44 ` Aharon Robbins
@ 2003-09-15 20:03   ` boyd, rounin
  0 siblings, 0 replies; 6+ messages in thread
From: boyd, rounin @ 2003-09-15 20:03 UTC (permalink / raw)
  To: 9fans

> This is a bug that was introduced when BWK switched from the lex scanner
> to a hand-written one.  (Guess who told him about it? :-)  It's fixed in
> the current version:

i understand that.  i'd prefer to mangle the test scripts than to hack awk.
my reasoning being is that the side effects of hacking the test script are
minimal, but hacking awk is fraught with peril (i knew that before i bio-fied
it).

the rand() based tests are pretty much useless.

the problem is to make the right choice :(




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

* Re: [9fans] awk bug
  2003-09-15  9:53 boyd
  2003-09-15 10:04 ` Geoff Collyer
@ 2003-09-15 11:44 ` Aharon Robbins
  2003-09-15 20:03   ` boyd, rounin
  1 sibling, 1 reply; 6+ messages in thread
From: Aharon Robbins @ 2003-09-15 11:44 UTC (permalink / raw)
  To: 9fans

In article <d2f8e7b66b79d38d34ac299d879b7c03@sdgm.net> you write:
>brahma% echo a b c | awk 'BEGIN { f[0] = 2 }
>		{ print $f[0] }
>		'
>awk: syntax error at line 2
> context is
>		{ print >>>  $f[ <<<
>awk: illegal statement at line 2
>brahma% echo a b c | awk '{ print $2 }'
>b

This is a bug that was introduced when BWK switched from the lex scanner
to a hand-written one.  (Guess who told him about it? :-)  It's fixed in
the current version:

	$ echo a b c | nawk 'BEGIN { f[0] = 2}
	> { print $f[0] }'
	b
	$ nawk -V
	awk version 20030731

Arnold


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

* Re: [9fans] awk bug
  2003-09-15 10:04 ` Geoff Collyer
@ 2003-09-15 10:14   ` boyd, rounin
  0 siblings, 0 replies; 6+ messages in thread
From: boyd, rounin @ 2003-09-15 10:14 UTC (permalink / raw)
  To: 9fans

> (maybe `($f)[0]' is the right parse), ...

roger that.  fixed the test and the plan 9 awk passes it.



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

* Re: [9fans] awk bug
  2003-09-15  9:53 boyd
@ 2003-09-15 10:04 ` Geoff Collyer
  2003-09-15 10:14   ` boyd, rounin
  2003-09-15 11:44 ` Aharon Robbins
  1 sibling, 1 reply; 6+ messages in thread
From: Geoff Collyer @ 2003-09-15 10:04 UTC (permalink / raw)
  To: 9fans

I'm not sure if `$f[0]' should work as you intend
(maybe `($f)[0]' is the right parse), but parentheses
can fix things to work as you intend:

; echo a b c | awk 'BEGIN { f[0] = 2 }
		{ print $(f[0]) }'
b


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

* [9fans] awk bug
@ 2003-09-15  9:53 boyd
  2003-09-15 10:04 ` Geoff Collyer
  2003-09-15 11:44 ` Aharon Robbins
  0 siblings, 2 replies; 6+ messages in thread
From: boyd @ 2003-09-15  9:53 UTC (permalink / raw)
  To: 9fans

brahma% echo a b c | awk 'BEGIN { f[0] = 2 }
		{ print $f[0] }
		'
awk: syntax error at line 2
 context is
		{ print >>>  $f[ <<<
awk: illegal statement at line 2
brahma% echo a b c | awk '{ print $2 }'
b


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

end of thread, other threads:[~2010-04-19 16:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-19 16:33 [9fans] awk bug erik quanstrom
  -- strict thread matches above, loose matches on Subject: below --
2003-09-15  9:53 boyd
2003-09-15 10:04 ` Geoff Collyer
2003-09-15 10:14   ` boyd, rounin
2003-09-15 11:44 ` Aharon Robbins
2003-09-15 20:03   ` boyd, rounin

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