Re: Bug in awk script...

2022-12-25 Thread Crystal Kolipe
On Mon, Dec 26, 2022 at 06:03:42AM +0800, wuwow...@gmail.com wrote:
> Sad... Not working...
> OpenBSD 7.1
> 
> #!/usr/bin/awk -f
> BEGIN {
>     d = "/tmp/test/";
>     system("mkdir -p " d);
>     i = -1;
>     while (++i < 1000) {
>  f = d i;
>  printf("") > f;
>  }
> }
> 
> awk: can't open file /tmp/wow/125
> 
> It' seems that "one true awk" is buggy...

Not really.  You just need to increase the limit for openfiles in
/etc/login.conf.



Re: Bug in awk script...

2022-12-25 Thread Theo Buehler
On Mon, Dec 26, 2022 at 06:03:42AM +0800, wuwow...@gmail.com wrote:
> Sad... Not working...
> OpenBSD 7.1
> 
> #!/usr/bin/awk -f
> BEGIN {
>     d = "/tmp/test/";
>     system("mkdir -p " d);
>     i = -1;
>     while (++i < 1000) {
>  f = d i;
>  printf("") > f;

This opens f and leaves it open. You should close(f) if you no longer
need it.

>  }
> }
> 
> awk: can't open file /tmp/wow/125

Since you didn't close f, you ran into a limit of open files.

> 
> It' seems that "one true awk" is buggy...
> 

I would argue your script is buggy. It happens to work in GNU awk since
that has some file reuse logic.



Bug in awk script...

2022-12-25 Thread wuwow...@gmail.com
Sad... Not working...
OpenBSD 7.1

#!/usr/bin/awk -f
BEGIN {
    d = "/tmp/test/";
    system("mkdir -p " d);
    i = -1;
    while (++i < 1000) {
 f = d i;
 printf("") > f;
 }
}

awk: can't open file /tmp/wow/125

It' seems that "one true awk" is buggy...