News for hackers. Stuff that matters.
Re:Shell Script Best Practices, from a decade of scripting t... by jb3689 on Thursday October 27, 2022 @03:00PM (#33362359)
I feel like the reasons for this are:

* Shell scripts force you to think in a more scalable way (data streams)

* Shell scripts compose rich programs rather than simplistic functions

* Shells encourage you to program with a rich, extensible feature set (ad-hoc I/O redirection, files)

The only times I don’t like shell scripts are when dealing with regex and dealing with parallelism

Re:Shell Script Best Practices, from a decade of scripting t... by chasil on Thursday October 27, 2022 @04:05PM (#33363274)
The POSIX shell does not implement regex.

What is used both in case/esac and globbing are "shell patterns." They are also found in variable pattern removal with ${X% and ${X#.

In "The Unix Programming Environment," Kernighan and Pike apologized for these close concepts that are easily mistaken for one another.

"Regular expressions are specified by giving special meaning to certain characters, just like the asterix, etc., used by the shell. There are a few more metacharacters, and, regrettably, differences in meanings." (page 102)

Bash does implement both patterns and regex, which means discerning their difference becomes even more critical. The POSIX shell is easier in memory for this reason, and others.

http://files.catwell.info/misc/mirror/

Re:Shell Script Best Practices, from a decade of scripting t... by gpderetta on Friday October 28, 2022 @03:03AM (#33368480)
> The only times I don’t like shell scripts are when dealing with regex and dealing with parallelism

Wow, for me parallelism is one of the best features of a unix shell and I find it vastly superior to most other programming languages.

Re:Shell Script Best Practices, from a decade of scripting t... by fomine3 on Friday October 28, 2022 @03:07AM (#33368494)
It's great for embarrassingly parallel data processing, but not good for concurrent/async task.
Re:Shell Script Best Practices, from a decade of scripting t... by partdavid on Friday October 28, 2022 @04:08PM (#33377144)
Can you expand on the parallelism features you use and what shell? In bash I've basically given up managing background jobs because identifying and waiting for them properly is super clunky; throttling them is impossible (pool of workers) and so for that kind of thing I've had to use GNU parallel (which is its own abstruse mini-language thing and obviously nothing to do with shell). Ad-hoc but correct parallelism and first class job management was one of the things that got me to switch away from bash.
Re:Shell Script Best Practices, from a decade of scripting t... by fluential on Sunday October 30, 2022 @08:26AM (#33393842)
GNU parallel