bug-gnu-utils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: /0/0 in gawk


From: Kenny McCormack
Subject: Re: /0/0 in gawk
Date: 9 Jan 2002 17:32:34 -0600

In article <address@hidden>,
Dan Jacobson <address@hidden> wrote:
>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?
>--
>http://www.geocities.com/jidanni/ Tel+886-4-25854780

Very funny.

You can simplify this to:

% gawk 'BEGIN {print /dev/stdout}'
0
%

And then analyze that.  It turns out that /dev/ is a reg exp that is
compared against the current line ($0) and returns 0 (false).  This
value is then converted to a string and concatenated with the value of
the variable stdout (which is a null string).  Hence, "0".



reply via email to

[Prev in Thread] Current Thread [Next in Thread]