From: Mike Frysinger <vapier@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Subject: Re: [gentoo-dev] Re: evar_push/pop helpers
Date: Mon, 17 Jun 2013 12:06:35 -0400 [thread overview]
Message-ID: <201306171206.35913.vapier@gentoo.org> (raw)
In-Reply-To: <201306170142.15784.vapier@gentoo.org>
[-- Attachment #1: Type: Text/Plain, Size: 1198 bytes --]
On Monday 17 June 2013 01:42:15 Mike Frysinger wrote:
> On Sunday 02 June 2013 13:38:04 Steven J. Long wrote:
> > On Sat, Jun 01, 2013 at 11:03:20PM -0400, Mike Frysinger wrote:
> > > +# is not specified, the var will be unset.
> > > +evar_push_set() {
> > > + local var=$1
> > > + evar_push ${var}
> > > + case $# in
> > > + 1) unset ${var} ;;
> > > + 2) eval ${var}=\$2 ;;
> >
> > I wish you wouldn't use eval for this. I know it's technically okay here,
> > or would be if you verified the parameter, but bash has printf -v for
> > this purpose:
>
> interesting, i hadn't seen that before ... looks new to bash-3.1. /me
> tucks that into his tool belt.
>
> although it doesn't quite work in the edge case where the value is an empty
> string. consider:
> unset x
> printf -v x ''
> echo ${x+set}
>
> that should show "set", but it does not. i'll have to keep `eval ${var}=`
> when the value we're setting is empty. or just keep the eval code since i
> have to do eval anyways at that point.
>
> i'll report it upstream to the bash guys.
looks like it can be worked around by doing:
printf -v x '%s' ''
which is arguably what we want anyways
-mike
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
next prev parent reply other threads:[~2013-06-17 16:06 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-02 3:03 [gentoo-dev] evar_push/pop helpers Mike Frysinger
2013-06-02 6:51 ` Michał Górny
2013-06-02 7:09 ` Mike Frysinger
2013-06-02 7:16 ` Michał Górny
2013-06-02 7:29 ` Mike Frysinger
2013-06-02 7:48 ` Tom Wijsman
2013-06-17 5:45 ` Mike Frysinger
2013-06-02 8:39 ` Michał Górny
2013-06-02 15:40 ` Mike Frysinger
2013-06-02 15:57 ` Andreas K. Huettel
2013-06-02 7:33 ` Tom Wijsman
2013-06-02 17:38 ` [gentoo-dev] " Steven J. Long
2013-06-17 5:42 ` Mike Frysinger
2013-06-17 16:06 ` Mike Frysinger [this message]
2013-06-17 5:46 ` [gentoo-dev] " Mike Frysinger
2013-06-17 17:51 ` Greg KH
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=201306171206.35913.vapier@gentoo.org \
--to=vapier@gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/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