Reputation
972
Top tag
Next privilege 1,000 Rep.
See votes, expandable usercard
Badges
2 9 25
Newest
 Custodian
Impact
~245k people reached

2d
comment Is an ISO image file a filesystem in its own right?
Puppy Linux makes heavy use of mounted ISO files. And because they contain supported file systems, they can be written to as well. The ROX-Filer file manager even allows them to be mounted and unmounted just by clicking on them. It's common to build images intended for a flash drive or SD card as a .iso file in the RAM filesystem or on disk and then just copy it (drag-n-drop) to the media.
Feb
17
comment POSIX regular expression match on first occurrence of string
I've been hacking at this off and on for a couple of years and found this question I submitted early on with more on the problems I'm trying to solve. I've written lots of scripts using getopt and getopts over the years, but have long been frustrated with their limitations. Yad and other more modern programs have convinced me to adopt long options to reduce bugs since they're more self-documenting. The optionArg() function as described in my answer below allows me to treat -- as a special "positional arguments" option to separate those out.
Feb
16
comment POSIX regular expression match on first occurrence of string
@cas ... In addition to avoiding external programs due to performance issues, getopt is designed to be used with a case statement which works best for mutually exclusive and independent options. Case statements almost always involve setting variables in order to use values repeatedly ("persistence"?). That gets messy.
Feb
16
comment POSIX regular expression match on first occurrence of string
To whoever down-voted... Please consider not down-voting everything you disagree with. Just because you don't understand the logic, doesn't make it wrong. Please limit down-votes to grossly misleading approaches. I've been writing shell scripts for over 30 years in many different shells as well as programming in about 40 different languages including C and assembly. My low rep here is because I seldom post... which is because every time I do, someone more concerned with quick answers than thinking through problems starts down-voting.
Feb
16
comment POSIX regular expression match on first occurrence of string
A good point @Gilles. But not a problem in this use case.
Feb
15
revised POSIX regular expression match on first occurrence of string
changed example to another function calling this function
Feb
15
revised POSIX regular expression match on first occurrence of string
why using regex... for performance
Feb
15
comment POSIX regular expression match on first occurrence of string
Thank you @Otheus. I wish to avoid for loops as they are quite slow in bash. Letting the C code within bash do iterations performs much better. Regex and Parameter Expansion accomplish that here. If I only needed to do this at script startup (the usual case), this would not be worth the effort. But this function is called by any other function that takes options (of which there are many) so performance is important.
Feb
15
asked POSIX regular expression match on first occurrence of string
Feb
15
answered POSIX regular expression match on first occurrence of string
Jan
31
awarded  Custodian
Jan
31
reviewed No Action Needed Rsyslog not creating dynamic directories
Jan
21
revised Catch “command not found” from shell script
realized that "file" was missing in $_executables
Jan
21
answered Catch “command not found” from shell script
Jan
9
comment Where are bash line continuations after && and || documented?
As you found, ending lines with && and || is not well documented and thus uncommon (except in your shop apparently). On seeing the example, my first thought was "syntax error". I've been writing shell script for decades and still had to look it up and run it to prove it is correct. Lines ending in '&' (run in background) are more common to me (and erroneous key repeats as well). Though this example works, using multiple && and || clauses is highly unreliable due to how they differ from the expected if-then logic. The epllipsis in english means "more to follow" so that makes more sense to me.
Jan
8
comment Where are bash line continuations after && and || documented?
I wish bash supported an ellipsis (...) for line continuation. It would prevent a lot of logic bugs. But we can't have everything.
Dec
24
awarded  Necromancer
Nov
18
awarded  Yearling
Nov
17
awarded  Popular Question
Oct
14
awarded  Nice Question