[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] PROCINFO["identifiers"], a bug
From: |
Andrew J. Schorr |
Subject: |
Re: [bug-gawk] PROCINFO["identifiers"], a bug |
Date: |
Tue, 28 Aug 2018 22:56:29 -0400 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Wed, Aug 29, 2018 at 12:17:16AM +0200, Petr Slansky wrote:
> I found this by an accident and I think it is a bug in gawk 4.1.3 and 4.1.4
>
> $ gawk 'BEGIN {for (KEY in PROCINFO) print KEY, PROCINFO[KEY];}'
> group9 116
> ppid 22129
> pgrpid 2890
> api_major 1
> group10 1000
> api_minor 1
> group1 4
> gid 1000
> mpfr_version GNU MPFR 4.0.1
> group2 20
> egid 1000
> group3 24
> gawk: cmd. line:1: fatal: attempt to use array `PROCINFO["identifiers"]' in
> a scalar context
That looks correct to me, because PROCINFO["identifiers"] is an array. You need
to recurse
into subarrays. Try this instead:
gawk 'function p(k, v, i) {if (isarray(v)) {for (i in v) p(k "[" i "]",
v[i])} else print k, v} BEGIN {for (k in PROCINFO) p(k, PROCINFO[k])}'
Take a look at the process_array example in the manual:
https://www.gnu.org/software/gawk/manual/html_node/Walking-Arrays.html
Regards,
Andy
- [bug-gawk] PROCINFO["identifiers"], a bug, Petr Slansky, 2018/08/28
- Re: [bug-gawk] PROCINFO["identifiers"], a bug,
Andrew J. Schorr <=
- Re: [bug-gawk] PROCINFO["identifiers"], a bug, Neil R. Ormos, 2018/08/29
- Re: [bug-gawk] PROCINFO["identifiers"], a bug, Wolfgang Laun, 2018/08/29
- Re: [bug-gawk] PROCINFO["identifiers"], a bug, arnold, 2018/08/29