On Sat, Jun 04, 2022 at 06:19:30PM +0200, Alessandro Barbieri wrote:
> When I use sed is for dynamic content and mostly like to do this:
> s|lib|$(get_libdir)|g
> In this case esed would be deleterious because it would fail on 32 bit
> arches

This case is noted in the docs fwiw. How to handle will depend on
preference but best route to ensure the change is always right
would be either to patch to replace lib by e.g. @GENTOO_LIBDIR@,
/then/ sed, or insert a variable/option that could be passed and
perhaps even upstreamed.

Lazier approach that use esed (or upcoming erepl) could be:

   [[ $(get_libdir) != lib ]] && erepl /lib /$(get_libdir) file

This also avoids unnecessarily editing files when there's nothing,
albeit more invasive and runs get_libdir twice. EPREFIX is a bit
nicer given we can use `use prefix`:

   use prefix && erepl /usr "${EPREFIX}"/usr file

This is a bit like replacing
   rm -f exists-with-USE-gui-only
by
   use !gui || rm exists-with-USE-gui-only || die
(bash exit code logic always fun wrt that double negation...)

Both are going to do the job at first, but one may end up missing
that the file was moved in another directory on bump and is now
getting wrongly installed.

-- 
ionen

Attachment: signature.asc
Description: PGP signature

Reply via email to