bug-gawk
[Top][All Lists]
Advanced

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

[bug-gawk] How to enable -L fatal but disable the shadow warnings?


From: Peng Yu
Subject: [bug-gawk] How to enable -L fatal but disable the shadow warnings?
Date: Mon, 8 Oct 2012 11:13:24 -0500

Hi,

-L fatal is sometimes useful. But it always warns shadowed variables,
which is not necessarily useful, because these variables are
intentionally shadowed in functions in most of cases. Is there a way
to disable these shadow warnings while keep -L fatal on?

~/linux/test/awk/bin/-L$ ./main_shadow.sh
echo 1 | awk -e 'function f(x) { print x; x=2 } { x=$1; f(x); print x }'
1
1
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.
echo | awk -L fatal -e '{ print x }'
awk: cmd. line:1: (FILENAME=- FNR=1) fatal: reference to uninitialized
variable `x'
echo | awk -L -e '{ print x }'
awk: cmd. line:1: (FILENAME=- FNR=1) warning: reference to
uninitialized variable `x'


~/linux/test/awk/bin/-L$ cat main_shadow.sh
#!/usr/bin/env bash

set -v
echo 1 | awk -e 'function f(x) { print x; x=2 } { x=$1; f(x); print x }'
echo 1 | awk -L fatal -e 'function f(x) { print x; x=2 } { x=$1; f(x);
print x }'
echo | awk -L fatal -e '{ print x }'
echo | awk -L -e '{ print x }'

-- 
Regards,
Peng



reply via email to

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