[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 03:45:59 -0700 |
User-agent: |
Heirloom mailx 12.4 7/29/08 |
> > If you want fatal errors:
> >
> > $ ./gawk --lint=fatal 'BEGIN { print x }'
> > gawk: cmd. line:1: fatal: reference to uninitialized variable `x'
>
> It doesn't just give errors for uninitialized variables. It gives out
> messages for other things as well. A way to just deal with the
> uninitialized variables would be appreciated.
>
> echo 1 | awk -L fatal -e 'function f(x) { print x; x=2 } { x=$1; f(x);
> print x }'
> awk: cmd. line:1: warning: function `f': parameter `x' shadows global variable
> awk: cmd. line:1: fatal: there were shadowed variables.
There is no way to just handle this issue. Instead, use --lint when you
run your program, and fix all the cases of use of uninitialized variables,
along with any other issues it reports.