News for hackers. Stuff that matters.
Re:When Bash scripts bite by dtoma on Thursday May 11, 2017 @11:50PM (#14321301)
Does error handling in your bash scripts ever become annoying enough to warrant a rewrite in, say, OCaml?
Re:When Bash scripts bite by MaxGabriel on Friday May 12, 2017 @01:07AM (#14321568)
For context, since I think some people don't know this and are down voting you, this blog post is from Jane Street (probably the largest commercial OCaml deployment?). As another poster noted Haskell has many tools/libraries for writing scripts which makes dtoma's question very reasonable.
Re:When Bash scripts bite by viraptor on Friday May 12, 2017 @12:18AM (#14321410)
Definitely not OCaml, but usually python or ruby will do the job better.
Re:When Bash scripts bite by BoorishBears on Friday May 12, 2017 @02:22AM (#14321820)
We use node at work now. The fact is it's not worth it trying to get everyone to write good bash scripts. Js doesn't have nearly as many foot guns and there's a library for just about anything you could want to do.
Re:When Bash scripts bite by mbrock on Friday May 12, 2017 @04:38AM (#14322318)
Error handling in asynchronous JavaScript is quite notorious for being easy to screw up.
Re:When Bash scripts bite by nilliams on Friday May 12, 2017 @05:23AM (#14322492)
True for async code, but if you use something like ShellJS [1] (which would be an easy way to rewrite a bash script that was getting out of hand), all commands are synchronous, so error handling is just try/catch.

[1] https://www.npmjs.com/package/shelljs

Re:When Bash scripts bite by moosingin3space on Friday May 12, 2017 @03:48PM (#14327279)
If only everyone used promises...I can dream, right?

Regardless, I'd actually prefer Haskell's do-notation for both asynchronous commands and shell-scripting tasks. Even though Haskell isn't my favorite language, do-notation is quite nice for this.

Re:When Bash scripts bite by foota on Friday May 12, 2017 @03:33AM (#14322082)
Just not left pad ;-)
Re:When Bash scripts bite by cgaebel on Friday May 12, 2017 @08:54AM (#14323537)
It's happened! We have some internal magic that lets us run ml directly: ./my_bash_script_replacement.ml, and it makes replacements fairly painless.

But we don't do it often. Each language has its strengths and weaknesses, and the constraints of a small script tend not to change that much over time. The script either starts other executables and pipes some text around, or it does some computation. The choice of which to use is often (but not always) clear.

Re:When Bash scripts bite by yminsky on Friday May 12, 2017 @12:56PM (#14325629)
I'm not sure I agree with the "don't do it often". Having jane-script (which is our OCaml scripting system) has allowed us to greatly reduce our dependence on Bash.

That said, there are still little things we use Bash for. But our tolerance for large bash scripts has diminished greatly over the years.

Re:When Bash scripts bite by ryanmccullagh on Friday May 12, 2017 @12:08AM (#14321375)
I believe OCaml would be a horrible choice as a replacement for bash
Re:When Bash scripts bite by Mathnerd314 on Friday May 12, 2017 @12:12AM (#14321390)
Haskell has several shell-scripting libraries: https://hackage.haskell.org/package/turtle https://hackage.haskell.org/package/shelly http://chrisdone.com/posts/shell-conduit

ocaml isn't that far off, just even less popular...

Re:When Bash scripts bite by emj on Friday May 12, 2017 @02:15AM (#14321789)
They do not seems to warrant further investigation, the examples you find about these implementations are overly simplified bordering useless. If you are going that way you might as well go with something like PowerShell, and that's a horrible scriping language.
Re:When Bash scripts bite by ujal on Friday May 12, 2017 @03:00AM (#14321978)
Funny how ShellCheck mentioned above is written in Haskell :)
Re:When Bash scripts bite by mseri on Saturday May 13, 2017 @05:15PM (#14333068)
You might want to have a look at [bos]

[bos]: http://erratique.ch/software/bos

Re:When Bash scripts bite by iblaine on Thursday May 11, 2017 @11:57PM (#14321330)
Nope.
Re:When Bash scripts bite by akhilcacharya on Friday May 12, 2017 @12:15AM (#14321400)
I wonder if the answer is the same if your name is Yaron Minsky :)
Re:When Bash scripts bite by mijoharas on Friday May 12, 2017 @06:01AM (#14322646)
I don't understand why you got downvotes, makes a lot of sense as a question (and made me smile) :).