Gentoo Archives: gentoo-dev

From: Ionen Wolkens <ionen@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [PATCH 1/2] esed.eclass: new eclass
Date: Fri, 03 Jun 2022 11:19:41
Message-Id: YpnuRO+FmKvON50P@eversor
In Reply to: Re: [gentoo-dev] [PATCH 1/2] esed.eclass: new eclass by Ionen Wolkens
1 On Fri, Jun 03, 2022 at 05:26:22AM -0400, Ionen Wolkens wrote:
2 > On Fri, Jun 03, 2022 at 09:14:05AM +0200, Ulrich Mueller wrote:
3 [...]
4 > > brittle. Also, don't use eval because it is evil.
5 >
6 > This is static evals, they're just evaluating a flat string and it's
7 > no different than.. well just running it as-is except it works around
8 > a noise issue (the 2>/dev/null doesn't register without it).
9 >
10 > eval is mostly evil when it's:
11 > eval "${expanded_variable}=${what_is_this_even}"
12 >
13 > Seeing eval "var=\${not_expanded}" as "evil" makes no sense to me,
14 > it's a harmless warning silencer. I feel this is just overreaction
15 > to the eval keyword (also in other dev ML post).
16 >
17 > To reproduce the warning:
18 > $ var=$(printf "\0") # var=$(<file-with-null-bytes)
19 > bash: warning: command substitution: ignored null byte in input
20 >
21 > doesn't work: var=$(printf "\0") 2>/dev/null
22 > works: eval 'var=$(printf "\0")' 2>/dev/null
23
24 Was experimenting for what else works just now.
25
26 { var=$(printf "\0"); } 2>/dev/null
27
28 I feel like I remember trying this before for qa-sed but don't remember
29 why I didn't use it (unlike subshells it does keep the var readable).
30
31 I still don't think that a flat eval was "evil" but if I have a way
32 to avoid it I'll use that instead.
33
34 --
35 ionen

Attachments

File name MIME type
signature.asc application/pgp-signature