[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [bug-gawk] Is there a way to automatically let gawk fail when an ini
From: |
arnold |
Subject: |
Re: [bug-gawk] Is there a way to automatically let gawk fail when an initialized variable is used? |
Date: |
Thu, 29 Nov 2018 00:41:15 -0700 |
User-agent: |
Heirloom mailx 12.4 7/29/08 |
Peng Yu <address@hidden> wrote:
> Hi,
>
> In certain cases, it may be useful to let gawk fail when an
> initialized variable is used. Of course, one can use if to test, but
> it can be cumbersome. Is there a way to do so automatically in gawk?
> Thanks.
>
> awk 'BEGIN { print typeof(x) }'
I assume you mean "uninitialized". This is what --lint is for:
$ ./gawk --lint 'BEGIN { print typeof(x) }'
gawk: cmd. line:1: warning: `typeof' is a gawk extension
gawk: cmd. line:1: warning: reference to uninitialized variable `x'
untyped
If you want fatal errors:
$ ./gawk --lint=fatal 'BEGIN { print x }'
gawk: cmd. line:1: fatal: reference to uninitialized variable `x'
RTFM
Arnold