|
Packit Service |
f629e6 |
# Date: Fri, 06 Jan 2006 14:02:17 -0800
|
|
Packit Service |
f629e6 |
# From: Paul Eggert <eggert@CS.UCLA.EDU>
|
|
Packit Service |
f629e6 |
# Subject: gawk misparses $expr++ if expr ends in ++
|
|
Packit Service |
f629e6 |
# To: bug-gawk@gnu.org
|
|
Packit Service |
f629e6 |
# Message-id: <87irsxypzq.fsf@penguin.cs.ucla.edu>
|
|
Packit Service |
f629e6 |
#
|
|
Packit Service |
f629e6 |
# Here's an example of the problem:
|
|
Packit Service |
f629e6 |
#
|
|
Packit Service |
f629e6 |
# $ gawk 'BEGIN{a=3}{print $$a++++}'
|
|
Packit Service |
f629e6 |
# gawk: {print $$a++++}
|
|
Packit Service |
f629e6 |
# gawk: ^ syntax error
|
|
Packit Service |
f629e6 |
#
|
|
Packit Service |
f629e6 |
# But it's not a syntax error, as the expression conforms to the POSIX
|
|
Packit Service |
f629e6 |
# spec: it should be treated like '$($a++)++'.
|
|
Packit Service |
f629e6 |
#
|
|
Packit Service |
f629e6 |
# Mawk, Solaris awk (old awk), and Solaris nawk all accept the
|
|
Packit Service |
f629e6 |
# expression. For example:
|
|
Packit Service |
f629e6 |
#
|
|
Packit Service |
f629e6 |
# $ echo '3 4 5 6 7 8 9' | nawk 'BEGIN{a=3}{print $$a++++}'
|
|
Packit Service |
f629e6 |
# 7
|
|
Packit Service |
f629e6 |
#
|
|
Packit Service |
f629e6 |
# This is with gawk 3.1.5 on Solaris 8 (sparc).
|
|
Packit Service |
f629e6 |
#
|
|
Packit Service |
f629e6 |
#
|
|
Packit Service |
f629e6 |
# #####################################################################################
|
|
Packit Service |
f629e6 |
# This Mail Was Scanned by 012.net AntiVirus Service1- Powered by TrendMicro Interscan
|
|
Packit Service |
f629e6 |
#
|
|
Packit Service |
f629e6 |
BEGIN { a = 3 }
|
|
Packit Service |
f629e6 |
|
|
Packit Service |
f629e6 |
{
|
|
Packit Service |
f629e6 |
print "in:", $0
|
|
Packit Service |
f629e6 |
print "a =", a
|
|
Packit Service |
f629e6 |
print $$a++++
|
|
Packit Service |
f629e6 |
print "out:", $0
|
|
Packit Service |
f629e6 |
}
|