[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[BUG]? Strange return values of close()
From: |
Jakub Martisko |
Subject: |
[BUG]? Strange return values of close() |
Date: |
Wed, 9 Feb 2022 15:44:03 +0100 |
Hello,
there seems to be some strange behaviour with the close (reproducer is
attached in case the formatting gets messed). Is the RC echo=2304 expected
or is this a bug? I've tested the same thing with the gawk-4.0.2 (i.e.
before the change described in) and it returns 2304 in all four cases.
Thanks,
Jakub
[1]:
https://www.gnu.org/software/gawk/manual/html_node/Close-Files-And-Pipes.html#FOOT29
$ ls
gwk_prog
$ gawk -f ./gwk_prog
RC Empty=9 #this is the expected value based on unzip's return values
RC echo=9
$ unzip -o ./test.zip 2>/dev/null; echo $?
9
$ touch ./test.zip
$ ls
gwk_prog test.zip
$ gawk -f ./gwk_prog
RC Empty=9
RC echo=2304 # this is 256*9 btw
$ unzip -o ./test.zip 2>/dev/null; echo $?
Archive: ./test.zip
9
$ cat gwk_prog
#!/usr/bin/gawk -f
BEGIN{
rc=0;
extract_file="unzip -o ./test.zip 2>/dev/null";
#Just an empty cycle - returns 9 as expected
while (extract_file|getline){
continue;
}
rc=close(extract_file);
print "RC Empty="rc;
#Non empty cycle - extract_file should return 9
while (extract_file|getline){
cmd="echo"
cmd|getline
close(cmd)
}
rc=close(extract_file);
print "RC echo="rc;
}
gwk_prog
Description: Binary data
- [BUG]? Strange return values of close(),
Jakub Martisko <=