Sujet : Re: Useless Use Of Regexes
De : ldo (at) *nospam* nz.invalid (Lawrence D'Oliveiro)
Groupes : comp.os.linux.miscDate : 26. Mar 2025, 01:42:08
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vrvigv$gce5$3@dont-email.me>
References : 1 2 3 4 5
User-Agent : Pan/0.162 (Pokrosvk)
On Tue, 25 Mar 2025 13:03:45 +0100, Marc Haber wrote:
This is a classic example why shellscripts are inferior. If you had
written that in python, you could just ingest iproute's output in a
python data structire and access it naturally.
>
A very wise German person, today a friend of mine, used to say 25
years ago: "Verwende perl. Shell will man können, dann aber nicht
verwenden." In English that would be "Use Perl. You want to be able
to use Shell, but then don't use it." Today, of course, that would
be python.
There is a certain challenge in seeing how far you can push things in
a shell script (or specifically, a bash script), before giving up and
switching to Python. For example, figuring out how to deal with
arbitrary file names, which might include funny characters like spaces
and newlines -- can that be done in bash? Yes it can. But maybe it’s
more trouble than it’s worth ...
My classic example of a large, yet well-written shell script is the
configure script for FFmpeg
<
https://git.videolan.org/?p=ffmpeg.git;a=tree;h=refs/heads/master;hb=refs/heads/master>.
It’s over 8000 lines. Obviously it must be handwritten, not generated
by GNU Autotools in the traditional way, because you can actually read
it and understand what it does.