[LTP] [PATCH 1/1] tst_net.sh: Declare prefix variable as empty

Petr Vorel pvorel@suse.cz
Mon Jul 12 18:12:30 CEST 2021


Hi all,

> in tst_ipaddr_un(). This is required to fix problem on dash, which
> (unlike bash and busybox ash implementation) takes value of previously
> defined variable, i.e.  guarding with local does not work:
> 
> $ foo=ee; bar() { local foo; echo "foo: '$foo'"; }; bar
> foo: 'ee'
> 
> It requires declare it as empty:
> $ foo=ee; bar() { local foo=; echo "foo: '$foo'"; }; bar
> foo: ''
> 
> This problem seems to be on various dash versions from 0.5.8 to
> 0.5.11+git20200708+dd9ef66-5 (on Debian oldstable, stable, testing).
> It'd require to set all variables, but now fix just prefix, which is
> used in build.sh and it's quite common name.

FYI this behavior is expected on dash, quoting man dash(1):
"When a variable is made local, it inherits the initial value and exported and
readonly flags from the variable with the same name in the surrounding scope, if
there is one."

Kind regards,
Petr


More information about the ltp mailing list