Deutsch English Français Italiano |
<vs70je$3gfnr$3@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Lawrence D'Oliveiro <ldo@nz.invalid> Newsgroups: comp.os.linux.misc Subject: Re: Useless Use Of Regexes Date: Fri, 28 Mar 2025 20:25:19 -0000 (UTC) Organization: A noiseless patient Spider Lines: 79 Message-ID: <vs70je$3gfnr$3@dont-email.me> References: <vrsfkv$1md7d$1@dont-email.me> <vrsjva$1oouq$1@dont-email.me> <vrso4m$1toah$3@dont-email.me> <sm0o6xpqxwf.fsf@lakka.kapsi.fi> <vru632$lb7$1@news1.tnib.de> <vrvigv$gce5$3@dont-email.me> <vs09u6$61ff$1@news1.tnib.de> <vs1lgs$2f333$2@dont-email.me> <vs1ou7$9qn3$1@news1.tnib.de> <vs23sj$2s4s3$1@dont-email.me> <vs2suo$cka4$1@news1.tnib.de> <vs2ugt$3nl2p$1@dont-email.me> <vs3s5l$f45n$1@news1.tnib.de> <vs4eja$14bph$1@dont-email.me> <vs60ng$2gkd0$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Fri, 28 Mar 2025 21:25:19 +0100 (CET) Injection-Info: dont-email.me; posting-host="325182479a91973218e539df1507a627"; logging-data="3686139"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+XFoOruUXkj724nwVsxSl+" User-Agent: Pan/0.162 (Pokrosvk) Cancel-Lock: sha1:TV9uPzkuEIdA14yfQVna0ktXrk0= Bytes: 3484 On Fri, 28 Mar 2025 12:21:20 +0100, marrgol wrote: > On 2025-03-27 at 22:05 Lawrence D'Oliveiro wrote: >> >> On Thu, 27 Mar 2025 16:51:16 +0100, Marc Haber wrote: >> >>> Lawrence D'Oliveiro <ldo@nz.invalid> wrote: >>> >>>> On Thu, 27 Mar 2025 07:58:32 +0100, Marc Haber wrote: >>>>> >>>>> You could have it easier with getopt ... >>>> >>>> Last I checked, getopt doesn’t do long options. >>> >>> You should check again. >> >> ldo@theon:~> help getopt getopts: getopts optstring name [arg ...] >> […] > > You're quoting help to 'getopts' shell built-in command -- > you are mistaking it for 'getopt' program from util-linux. I had a look at that, too. Here’s an extract from the example script /usr/share/doc/util-linux/examples/getopt-example.bash demonstrating the use of the getopt(1) command from util-linux: ---- TEMP=$(getopt -o 'ab:c::' --long 'a-long,b-long:,c-long::' -n 'example.bash' -- "$@") if [ $? -ne 0 ]; then echo 'Terminating...' >&2 exit 1 fi # Note the quotes around "$TEMP": they are essential! eval set -- "$TEMP" unset TEMP while true; do case "$1" in '-a'|'--a-long') echo 'Option a' shift continue ;; '-b'|'--b-long') echo "Option b, argument '$2'" shift 2 continue ;; '-c'|'--c-long') # c has an optional argument. As we are in quoted mode, # an empty parameter will be generated if its optional # argument is not found. case "$2" in '') echo 'Option c, no argument' ;; *) echo "Option c, argument '$2'" ;; esac shift 2 continue ;; '--') shift break ;; *) echo 'Internal error!' >&2 exit 1 ;; esac done ---- Doesn’t seem to me that’s saving much effort. Does it look like a saving of effort to you?