Re: good patch vs. sed fixes

"Xi Ruoyao" ([email protected] via blfs-dev Mailing List) <[email protected]>
Newsgroups gmane.linux.lfs.beyond.devel
Message-ID <[email protected]>
On Thu, 2024-11-21 at 03:40 +0100, Uwe Düffert wrote:
> Hi all,
> 
> I'm not sure it is worth the effort, but from time to time I stumble 
> across the "problem" that certain sed or patch commands would apply 
> multiple times although they should not. I'm fully aware this is 
> unsupported "deviating from the book" but it happens. I'm trying to build 
> some not-yet-in-the-book new version, something fails, I fix the problem 
> and try again, then some unexpected "double sed" or "double patch" 
> silently breaks stuff. Sure, I should have done it cleanly from scratch, 
> but the nature of the fixed problem suggested I could just repeat the 
> build...

Then why not just issue "./mach build"?  Why the sed is ever executed
again?

/* snip */

> I do like the idea to fix stuff with a simple sed if it helps avoiding a 
> patch, BUT only if it does the job similarily well.

It is doing things similarity well.  If not it wouldn't be in the book
in the first place.

> I kind of appreciate 
> the educational value of a sophisticated sed, but in my experience 
> a unified patch is less likely to "doubly apply" (though it happened to me 
> before) and sometimes makes clearer what actually needs to be changed.
> 
> I'm not proposing using some more official patch such as 
> https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=d9712b1358dc1b64933c3090d72153aae3270f25 
> in this case, I'd just like to mention that this patch 1) makes the 
> idea more clear (there are not just 5 more CLASS_CHARACTERs but they do 
> have names)

The names are not relevant.  I can rewrite the command as

for i in AKSARA AKSARA_PREBASE AKSARA_START VIRAMA_FINAL VIRAMA; do
   sed -i '/ZWJ/s/}/,CLASS_CHARACTER&/' intl/lwbrk/LineBreaker.cpp 
done

but this is just meaningless to 99.99% BLFS users (who are not an ICU
developer, nor a Mozilla developer, nor a linguist).

> and it does not apply multiple times...

Again, when I just did a code fix to Firefox I just run "./mach build"
and I don't understand why the sed would be executed again.

Sometimes I do deliberately make a sed no-op if applied twice.  But it's
only a bonus, not something we need to guarantee.  And sometimes such a
bonus is a bad thing: when we update the package to a new version where
the fix is already upstream, the editor can easily forget to remove the
sed which is no-op now.  (OTOH if it's just "double applied" the build
fails and the editor immediately notice it.)

-- 
Xi Ruoyao <[email protected]>
School of Aerospace Science and Technology, Xidian University

-- 
http://lists.linuxfromscratch.org/sympa/info/blfs-dev
Unsubscribe: See the above information page
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.