From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 1/1] tst_net.sh: Declare prefix variable as empty
Date: Mon, 12 Jul 2021 18:12:30 +0200 [thread overview]
Message-ID: <YOxp7pwIQKDiT3bs@pevik> (raw)
In-Reply-To: <34959e10-45fc-f7ea-9e2d-ebe186a97859@jv-coder.de>
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
prev parent reply other threads:[~2021-07-12 16:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-09 14:01 [LTP] [PATCH 1/1] tst_net.sh: Declare prefix variable as empty Petr Vorel
2021-07-12 2:00 ` Li Wang
2021-07-12 5:49 ` Petr Vorel
2021-07-12 5:57 ` Joerg Vehlow
2021-07-12 6:40 ` Petr Vorel
2021-07-12 16:12 ` Petr Vorel [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YOxp7pwIQKDiT3bs@pevik \
--to=pvorel@suse.cz \
--cc=ltp@lists.linux.it \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox