bug-gnu-utils
[Top][All Lists]
Advanced

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

exit


From: jozef . kutej
Subject: exit
Date: Tue, 3 Feb 2004 13:41:16 +0100
User-agent: Mutt/1.4.1i

Hello!

I have a problem with setting return value to zero once it's nonzero. As you
see setting it to different nonzero value is ok.


awk 'BEGIN { "exit 1" | getline dif } END { exit 0 }' < /dev/null; echo $?
sh: line 1: xxx: command not found
1

awk 'BEGIN { "exit 1" | getline dif } END { exit 2 }' < /dev/null; echo $?
sh: line 1: xxx: command not found
2

awk 'BEGIN { "exit 1" | getline dif ; "echo" | getline dif } END { exit 0 }' <
/dev/null; echo $?
sh: line 1: xxx: command not found
1

awk 'BEGIN { "echo" | getline dif } END { exit 0 }' < /dev/null; echo $?
0

awk --version
GNU Awk 3.1.3


I found out that on the end of awk program execution you have

mail.c

    if (close_io() != 0 && exit_val == 0)
        exit_val = 1;

probably the filedescriptor remains as open and the function

gawk_pclose

returns the proces status which is of course nonzero

return rp->status;

May be after pipe operation you shoud close and free the descriptor.

So it's up to you to decide if this behavior is OK. But please len me know
if you consider this as a bug and would solve it or i would have to start to
use another return code for success as zero.

Thank you very much.

Jozef.





reply via email to

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