[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gawk] command line variable assignments
From: |
Stepan Kasal |
Subject: |
Re: [gawk] command line variable assignments |
Date: |
Thu, 16 May 2002 12:19:43 +0000 (UTC) |
User-agent: |
slrn/0.9.6.2 (Linux) |
On Thu, 16 May 2002 02:06:32 -0700, Tom Lord <address@hidden> wrote:
> Versions 3.0.3 and 3.0.6 both seem to think that an "=" in a
> command line argument indicates a variable assignment rather
> than a filename. As I read the spec, this is so only if the
> text to the left of the "=" begins with an underscore or letter and
> contains only characters which are valid in identifiers -- otherwise
> the argument must be treated as a filename.
>
> In other words:
>
> ./gawk [....] /foo/bar/=dir/etc
>
> is not a syntax error or bad variable assignment -- it tells awk to
> read its input from the named file.
Hallo,
the current version of GNU awk, 3.1.1, has it (almost) right.
The only problem might be that the messages are sometimes a bit confusing.
$ ./gawk -v ./=file 1
gawk: `./=file' argument to `-v' not in `var=value' form
Usage: ....
$ ./gawk --lint -v ./=file 1
gawk: warning: invalid syntax in name `./' for variable assignment
gawk: `./=file' argument to `-v' not in `var=value' form
Usage: .....
$ ./gawk 1 ./=file
gawk: cmd. line:2: fatal: cannot open file `./=file' for reading
(No such file or directory)
$ ./gawk --lint 1 ./=file
gawk: cmd. line:2: warning: invalid syntax in name `./' for variable assignment
gawk: cmd. line:2: fatal: cannot open file `./=file' for reading
(No such file or directory)
$ echo foo >./=file
$ ./gawk 1 ./=file
foo
$ ./gawk --lint 1 ./=file
gawk: cmd. line:2: warning: invalid syntax in name `./' for variable assignment
foo
Cheers,
Stepan Kasal