Gentoo Archives: gentoo-dev

From: Ionen Wolkens <ionen@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [PATCH 0/2] Add esed.eclass for sed that dies if caused no changes
Date: Fri, 03 Jun 2022 05:01:20
Message-Id: YpmVlyGj2iq/VBta@eversor
In Reply to: Re: [gentoo-dev] [PATCH 0/2] Add esed.eclass for sed that dies if caused no changes by Anna V
1 On Fri, Jun 03, 2022 at 09:47:51AM +0500, Anna V wrote:
2 > On 2022-06-03 00:45, Ionen Wolkens wrote:
3 > > On Fri, Jun 03, 2022 at 06:09:38AM +0200, Michał Górny wrote:
4 > > > On Tue, 2022-05-31 at 07:23 -0400, Ionen Wolkens wrote:
5 > > > > Often preferable to use patches so this happens, but sed have its
6 > > > > uses/convenience and this intend to help reduce the amount of old
7 > > > > broken seds causing issues that go unnoticed on bumps.
8 > > > >
9 > > > > Inspired by app-portage/iwdevtools' qa-sed (warns on any seds), but
10 > > > > this is for more deterministic use in ebuilds.
11 > > > >
12 > > > > Also slightly shortens sed use, -i is default, and no need to || die.
13 > > > > (see @EXAMPLE in eclass for a quick usage overview).
14 > > > >
15 > > >
16 > > > To be honest, I strongly dislike this. It really feels like trying to
17 > > > make an adapter for a square wheel, while the right solution would be to
18 > > > replace the wheel. On top of that, ton of evals which are pretty much
19 > > > a huge "no-no".
20 > >
21 > > About evals, the two eval is just to silence this:
22 > >
23 > > var=$(printf "\0")
24 >
25 > printf -v var "\0"
26
27 That was just for the sake of showing what happens, the eclass is
28 reading a file and isn't using printf. aka: var=$(<file)
29
30 >
31 > > The 2>/dev/null doesn't work without wrapping it, aka
32 > >
33 > > eval 'var=$(printf "\0")' 2>/dev/null
34 > >
35 > > No variables are expanded pre-eval so it's just evaluating a
36 > > static statement. eval can be removed, but it'll be noisy
37 > > if someone happens to sed binary files.
38 > >
39 > > >
40 > > > Perhaps it would be better to forget about trying to work miracles with
41 > > > sed and instead write a trivial shell replacement for the most common
42 > > > use cases. One thing I'd love to see is a simple substitution command
43 > > > that would work for paths/CFLAGS on RHS without having to worry about
44 > > > them conflicting with the pattern delimiter.
45 > > >
46 > > > --
47 > > > Best regards,
48 > > > Michał Górny
49 > > >
50 > > >
51 > >
52 > > --
53 > > ionen
54 >
55 >
56 >
57
58 --
59 ionen

Attachments

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