On 27 Oct 2002, Steve Elkins wrote:
> Does what follows reveal a bug or am I misusing the awk macro?
Basically, you are ignoring the following passage of the Scsh manual, just
If there is no after clause, awk returns the loop's state variables as
> Now wrap it in -e ...
> Error: returning zero values when one is expected
> Other versions used force-output to make the error appear at the end.
> Now put (zap '!) in <state-var-decls> ...
> Why does wrapping the expression in -e cause the error and why does
> adding (zap '!) to <state-var-decls> fix/conceal it?
Here's what I think happens: in the first version, since you run the code
as a script, the continuation K that eats the value(s) of the LET form
accepts any number of values. But the LET form returns the value(s) of
the AWK form, therefore the latter may return 0 values as it actually
does (since there are no state variables). In the second case, since you
have wrapped the LET form in the entry procedure, the continuation K
expects 1 value. (The entry procedure should return the exit status or
so, in other words, it is called in a context requiring a single return
value.) But the AWK form still returns nothing, and that's not enough
here. In the third version, the AWK form has got 1 loop variable instead
of 0 before, and consequently 1 return value, just what the continuation
expects. That is, repent and change your ways, it was your fault.