From owner-freebsd-questions Thu Jun 8 10: 8:17 2000 Delivered-To: freebsd-questions@freebsd.org Received: from mta02-svc.server.ntlworld.com (mta02-svc.ntlworld.com [62.253.162.42]) by hub.freebsd.org (Postfix) with ESMTP id 22C9237BAA8 for ; Thu, 8 Jun 2000 10:08:14 -0700 (PDT) (envelope-from mark@ukug.uk.freebsd.org) Received: from parish.my.domain ([62.253.85.224]) by mta02-svc.server.ntlworld.com (InterMail vM.4.01.02.27 201-229-119-110) with ESMTP id <20000608180748.WNWP10065.mta02-svc.server.ntlworld.com@parish.my.domain>; Thu, 8 Jun 2000 18:07:48 +0000 Received: (from mark@localhost) by parish.my.domain (8.9.3/8.9.3) id SAA00903; Thu, 8 Jun 2000 18:08:07 +0100 (BST) (envelope-from mark) Date: Thu, 8 Jun 2000 18:08:06 +0100 From: Mark Ovens To: Aaron Jeremias Luz Cc: questions@freebsd.org Subject: Re: Is awk(1) broken? Message-ID: <20000608180806.A233@parish> References: <20000602005307.B535@parish> <20000606005300.A371@thud.rochester.rr.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0.1i In-Reply-To: <20000606005300.A371@thud.rochester.rr.com>; from aaron@csh.rit.edu on Tue, Jun 06, 2000 at 12:53:00AM -0400 Organization: Total lack of Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Tue, Jun 06, 2000 at 12:53:00AM -0400, Aaron Jeremias Luz wrote: > On Fri, Jun 02, 2000 at 12:53:07AM +0100, Mark Ovens wrote: > > A script I'm writing which reads the ports INDEX file using awk(1) > > includes this line: > > > > cat INDEX | awk s=${cmd} 'BEGIN { FS = "|" } {if (index($1, s)..... > > > > But this gives the error: > > > > awk: cmd. line:2: fatal: illegal name `BEGIN {FS ' in variable > > assignment > > If you don't use the -v parameter, you can only specify variable > assignments on the command line as filenames. (See the bottom of > page 4 of the awk man page.) Yes, I read that but is: cat filename | awk s=${cmd} 'BEGIN { FS = "|" }..... not, in effect, the same as: awk s=${cmd} 0 'BEGIN { FS = "|" }..... 0 being stdin? Also in the POSIX COMPATIBILITY section of the manpage it states that ``-v'' is only to *force* assignment before BEGIN is executed (to model the behaviour of early versions), irrespective of whether there are any filenames on the command line, or not, and whether they are before or after the var=val. > A quick experiment shows that gawk gawk, hmmm, the manpage is for gawk but there is no gawk binary, or even a link to awk, so are you using the version that comes with FreeBSD? > will actually interpret a filename that has an equal sign in as an > assignment -- even if the file exists! > > I am not able to reproduce the error above, but I believe it > must involve some problem with shell expansion. I tried replacing ``s=${cmd}'' with ``s=emacs'' but got the same results. When I get time I will look at the source for awk because it's behaviour is definitely different the manpage. > > Hope this helps, > Aaron > > Disclaimer: My system (a 486 running 3.1-RELEASE) is showing bit-rot, > and it's time for me to go to bed. :-) -- ...and on the eighth day God created UNIX ________________________________________________________________ FreeBSD - The Power To Serve http://www.freebsd.org My Webpage http://ukug.uk.freebsd.org/~mark/ mailto:mark@ukug.uk.freebsd.org http://www.radan.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message