News for hackers. Stuff that matters.
Re:When Bash scripts bite by nialv7 on Friday May 12, 2017 @01:44AM (#14321690)
Why write new bash scripts in this day and age...
Re:When Bash scripts bite by zwischenzug on Friday May 12, 2017 @02:41AM (#14321902)
This is not so unreasonable a question, but the answer is simple: because it's ubiquitous, fairly standardised, and well supported.

Also, other languages suck at doing small things quickly and simply. Try rewriting a shell script in go with little experience and see how long it takes.

Re:When Bash scripts bite by riquito on Friday May 12, 2017 @02:12AM (#14321784)
They are fast, ubiquitous, 0-dependencies, short, espressive... most of the time. The fact is that we don't have anything better to glue commands together (afaik).
Re:When Bash scripts bite by Slackwise on Friday May 12, 2017 @09:03AM (#14323604)
> 0-dependencies

Actually, quite the opposite. All that shell scripts do is glue together other programs they depend on.

That makes them not portable. You can't just move a bash script from Linux to macOS because it uses ancient pre-GPLv3 versions of bash and all the other GNU utils.

Re:When Bash scripts bite by jstimpfle on Friday May 12, 2017 @09:59AM (#14323983)
Just use POSIX-compatible sh instead of bash. It's also not hard to use mostly POSIX-compatible commands (grep, sed, cat, cp, mkdir ...).

For scripts where you need something unstandardized, say, imagemagick, you would wind up with up with a dependency in most other languages as well.

Re:When Bash scripts bite by virtualized on Friday May 12, 2017 @03:27AM (#14322062)
"Glueing commands together" is called programming. That's what programming languages are for. Bash etc are just really bad programming languages that lure you into a trap of unnecessary complexity with their superstitial expressiveness for the happy path in short programs, when you don't need anything besides the built-ins. Decades of ubiquitous UNIX crap tricked you into believing that bash's properties are advantages rather that disadvantages. Sure, you can "glue together" a few commands quickly, but only at the price of horrible edge cases and hours of StackOverflowing for doing the simplest of things.
Re:When Bash scripts bite by logicallee on Friday May 12, 2017 @04:05AM (#14322199)
>but only at the price of horrible edge cases and hours of StackOverflowing for doing the simplest of things.

Or seconds, after you learn the search term "Perl one-liner" and add it to your queries for all your edge cases.

Start thinking of perl -we as a Bash built-in function.

Suddenly edge cases go from hours to your typing speed into Google.

Don't forget to leave a comment with a link to where you found the solution, what it does according to that site, and an apology for the unreadable line noise. If you make changes to what you copy and paste, explain your changes in a comment.

(Just in case it sounds sarcastic or ironical, this comment is serious and how I really work. I am really glad for my comments whenever I revisit old scripts.)

Re:When Bash scripts bite by PapaSpaceDelta on Friday May 12, 2017 @05:09AM (#14322452)
One reason is that any System Administrator can be expected to be able to understand and maintain Bash scripts.

I recently built a fairly complex system entirely in Bash, not because it was the "best" language for the job (it would have been much easier to do in Ruby or Python), but because the client didn't have any permanent staff that could maintain Ruby or Python scripts.

As a contractor, one of the major factors in the technical decisions I make is: how supportable is this technology for the client, once I have left? Of course the answer to that question will vary on a case by case basis, but Bash is usually a good lowest common denominator in a Linux environment.

Re:When Bash scripts bite by chedabob on Friday May 12, 2017 @04:12AM (#14322223)
Yeah, in the OP why wouldn't you make the same LDAP query using any of the numerous libraries available for other languages? I'll take the tiniest little bit of complexity of having to make sure Python and PiP are installed on my environment, over a Bash script falling apart at the seams from an edge case.
Re:When Bash scripts bite by kbart on Friday May 12, 2017 @03:05AM (#14321987)
It's not in fashion anymore or what? If it gets the job done, that's all I need.
Re:When Bash scripts bite by Sean1708 on Friday May 12, 2017 @10:07AM (#14324033)
Because Bash is horrible, but occasionally it's still the best tool for the job.