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

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

Re: [gawk] Test return value of awk statement


From: Chris Jones
Subject: Re: [gawk] Test return value of awk statement
Date: Mon, 26 Jan 2009 14:34:52 -0500
User-agent: Mutt/1.5.13 (2006-08-11)

On Sat, Jan 24, 2009 at 08:02:57PM EST, Dan Henry wrote:
> On Sat, 24 Jan 2009 19:48:06 -0500, Chris Jones <address@hidden>
> wrote:
> 
> >I'm trying to figure out how I can test the return value of a printf
> >statement in an awk script.

> >printf "format", variable
> >if (condition==bad) {exit 1}               # if printf failed, exit

> >I have been unable to find what the "condition" in the pseudo-awk
> >above might be.

> Why would it fail?  stdout closed?  Anyway, I can't answer
> definitively, but am interested and thus I suggest you ask on
> comp.lang.awk also.

The answer is that you can't.

In gawk at least, getline, close(), and system() appear to be the only
awk statements that return a value, possibly because they are
implemented as functions (?) but print & printf do not .. not very
consistent and somewhat confusing when you're skimming through the awk
manual trying to learn the basics in a rush.

CJ














reply via email to

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