bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] Possible errata in pdf version 4.2


From: Andrew J. Schorr
Subject: Re: [bug-gawk] Possible errata in pdf version 4.2
Date: Fri, 4 Jan 2019 16:49:31 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

Hi,

On Wed, Jan 02, 2019 at 03:00:33PM +0000, bamber ward wrote:
> In the pdf version of the manual ( version 4.2) there appears to be a
> problem
> 
> with getpwent() and getgrent() in Chapter 10. Both functions return the
> same result each time.

I don't see that:

bash-4.2$ gawk -i passwd 'BEGIN {while ((x = getpwent()) != "") print x}' | head
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
news:x:9:13:news:/etc/news:

> I give details for getpwent() only. In the call to getpwent() , after
> 
> _pw_init() _pw_count is 0 so the same result is returned each time.

That is not true. The _pw_init() function starts with this code:
    if (_pw_inited)
        return
So there's a flag variable that causes it to exit immediately after
the first call.

> Should
> the function be defined as follows:
> 
> 
> 
>       function getpwent()
> 
>        {
> 
>            _pw_init()
> 
>            while (_pw_count < _pw_total)
> 
>               {print _pw_bycount[++_pw_count]} # I always use braces
> 
>           return ""
> 
> }

No -- the function is supposed to return an entry, not print all the entries.

> In 12.3 Caution there appears to be a typo i.e “noone”

Thanks, but I don't see that in the current info manual. It seems to have
been fixed at some point.

> I have ubuntu 16.4. In the Chapter 13 , everthing works fine for guide.awk
> but the final translations are not made. I have unset LANGUAGE  but this
> not alter matters. Perhaps you could suggest workarounds ( if any exist )
> for this in future editions.This topic comes up fairly regularly in the
> ubuntu forums.

Do you have some sample code to reproduce the problem? That would be
super helpful.

>  In 16.7.4 should -i inplace be -i inplace.awk for the Command Line
> examples ?

I don't think so, because gawk tries using the ".awk" extension by default.

Regards,
Andy



reply via email to

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