[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gawk exit doesn't exit promptly
From: |
Jürgen Kahrs |
Subject: |
Re: gawk exit doesn't exit promptly |
Date: |
Sat, 03 Jan 2009 18:33:01 +0100 |
User-agent: |
Thunderbird 2.0.0.18 (X11/20081112) |
Andrew J. Schorr schrieb:
> On Fri, Jan 02, 2009 at 12:59:23PM -0500, Boemker, Tim wrote:
>> $ cat a
>> a
>> $ tail -f a | gawk '{ print "exiting"; exit }'
>> exiting
>
> I tried on my machine, and gawk exits fine. I think you
> may be unhappy because the "tail -f" command does not
> exit. As a result, the command keeps waiting. If you
> go into another shell and run "echo b >> a", then you
> will see that the entire pipeline will exit because
> the "tail -f" command will get a SIGPIPE when it tries
> to write to the nonexistent gawk process.
Andrew is right here. Don't use the -f and it will work.
Apart from this, I vaguely remember that Kernighan's
original AWK really needed the "exit" when printing
after BEGIN. That's the reason why some peopler today
still insist that a "Hello, world" program in AWK
has to look like this:
http://helloworldsite.he.funpic.de/hello.htm#awk
BEGIN {
print "Hello World!"
exit
}
Old AWK interpreters like Solaris oawk really need the
"exit", while modern implementations don't need it.
But, remember, the OP asked about something different.