Sujet : Re: Useless Use Of Regexes
De : mh+usenetspam1118 (at) *nospam* zugschl.us (Marc Haber)
Groupes : comp.os.linux.miscDate : 27. Mar 2025, 07:58:32
Autres entêtes
Organisation : private site, see http://www.zugschlus.de/ for details
Message-ID : <vs2suo$cka4$1@news1.tnib.de>
References : 1 2 3 4 5 6 7 8 9 10
User-Agent : Forte Agent 6.00/32.1186
Lawrence D'Oliveiro <
ldo@nz.invalid> wrote:
On Wed, 26 Mar 2025 21:43:51 +0100, Marc Haber wrote:
>
Lawrence D'Oliveiro <ldo@nz.invalid> wrote:
>
On Wed, 26 Mar 2025 08:21:42 +0100, Marc Haber wrote:
It has become better since I usually start off with ChatGPT which
takes care of the boilerplate stuff.
>
The main point of using a very-high-level language (like bash) is that
you shouldn’t need any boilerplate stuff.
As soon as you make it flexlbie, with command line options, you begin
typing getopt or GetOptions stuff and that's pretty much boilerplate.
>
Well, I do do that. Mainly it’s just a loop, though, e.g.
>
for ((;;)); do
if [ "${1:0:2}" != "--" ]; then
break
fi
if [ "$1" == "--" ]; then
shift
break
fi
opt="${1:2:${#1}}"
shift
val="${opt#*=}"
if [ "$val" = "$opt" ]; then
val=""
fi
opt="${opt%%=*}"
if [ "$opt" = "animation" ]; then
animation=1
elif [ "$opt" = "blender" ]; then
blender="$val"
elif [ "$opt" = "camera" ]; then
camera="$val"
elif [ "$opt" = "collections" ]; then
collections="$val"
elif [ "$opt" = "crash-protect" ]; then
crash_protect=1
elif [ "$opt" = "crash-retry-count" ]; then
crash_retry_count="$val"
elif [ "$opt" = "digits" ]; then
digits="$val"
...
else
opterror "bad option $opt"
fi
done
>
I would say, only a few lines in there count as “boilerplate” ...
All of them. You could have it easier with getopt, but oh my.
Greetings
Marc
-- ----------------------------------------------------------------------------Marc Haber | " Questions are the | Mailadresse im HeaderRhein-Neckar, DE | Beginning of Wisdom " | Nordisch by Nature | Lt. Worf, TNG "Rightful Heir" | Fon: *49 6224 1600402