bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] Another typeof() issue


From: Hermann Peifer
Subject: Re: [bug-gawk] Another typeof() issue
Date: Tue, 30 Jun 2015 19:41:16 +0200
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.7.0

On 2015-06-28 22:28, Hermann Peifer wrote:

$ echo "abc 123" > data
$ echo '{print typeof($1), typeof($2)}' > test.awk

# Expected types: string strnum
$ awk -f test.awk data
strnum strnum

The updated manual says about the above result:
> This is all as expected: field data has the STRNUM attribute

Doesn't the cross-referenced manual section say that field data, etc. only get the STRNUM attribute if they look like a number, otherwise they have the string attribute?

And wrt the below example, the updated manual says that the debugger evaluated '$2' and concluded that 123 is indeed a string. I might be missing/mis-reading something, but a value of 123 as part of user data "looks like a number", to me.

Somewhat puzzled. Hermann


# Debugging returns the opposite of the expected results
$ printf 'w $1 \n w $2 \n r \n n \n n' | awk -D -f test.awk data
Watchpoint 1: $1
Watchpoint 2: $2
Starting program:
Stopping in Rule ...
Watchpoint 1: $1
   Old value: ""
   New value: "abc"
main() at `test.awk':1
1       {print typeof($1), typeof($2)}
Watchpoint 2: $2
   Old value: ""
   New value: "123"
main() at `test.awk':1
1       {print typeof($1), typeof($2)}
strnum string  # ???





reply via email to

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