[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: /0/0 in gawk
From: |
Aharon Robbins |
Subject: |
Re: /0/0 in gawk |
Date: |
Fri, 11 Jan 2002 09:30:03 +0200 |
> To: address@hidden
> From: Dan Jacobson <address@hidden>
> Subject: /0/0 in gawk
> Date: 08 Jan 2002 19:52:16 +0800
>
> OK, I forgot to quote "/dev/stdout" [GNU Awk 3.1.0]:
>
> $ awk 'BEGIN{print "b" /dev/stdout}'
> awk: cmd. line:1: fatal: division by zero attempted
> $ awk 'BEGIN{print "b"> /dev/stdout}'
> $ ls -l 0
> -rw-r--r-- 1 jidanni jidanni 2 01 8 19:55 0
>
> OK, my question is why can it make a 0 out of /../.. when making a
> filename, but not otherwise? Shame, shame. /../.. must be "new
> math".
>
> ok, I get it. the first one is "b"/0/0, ["b"==0], and the second one
> is 0/0/, but what is /0/0?
> At least the second one is a bug?
There are no bugs here. The first is the equivalent of 0 / 0 / 0.
The value "b" becomes 0. The variables `dev' and `stdout' are
automatically initialized to zero. In the case of the
redirection, it's parsed as
print "b" > ( (/dev/) stdout )
The `/dev/' is the same as ($0 ~ /dev/), which in this case is zero,
concatenated with the empty string value of the variable `stdout'.
This leads to a filename of "0".
This is explained in the gawk documentation.
Arnold
- /0/0 in gawk, Dan Jacobson, 2002/01/09
- Re: /0/0 in gawk,
Aharon Robbins <=