top | item 40437508

(no title)

lifeofguenter | 1 year ago

Impressive project.

But I always feel that if you reach a certain complexity in your bash scripts, you should rather pivot to any other $lang.

Bash scripts should be simple glue between programs (unix-principle).

discuss

order

DaSHacka|1 year ago

> Bash scripts should be simple glue between programs

If a script is literally just running a list of commands and occasionally piping the output from one to another, you may as well make it POSIX compliant (therefore a sh script) since you're not using any features of Bash anyway.

> But I always feel that if you reach a certain complexity in your bash scripts, you should rather pivot to any other $lang.

This is a common critique, but what other lang?

I make Bash scripts all the time for system administration tasks, and they largely just werk™ as long as you have Bash (90% of the time pre-installed) and the necessary commands. From there, any command can be readily called, piped, or saved to variables/arrays, and Bash has powerful (enough) native math and string manipulation capabilities.

Meanwhile with Python there's always some hassle installing dependencies with pip(x) and virtual environments, plus the unfortunate rare Python 2 encounter where you either gotta rewrite the whole thing in python 3 or figure out how to install the old Python 2 runtime and 3rd party python 2 libraries used in the script on your distro.

I don't see the appeal of sonething like the OP though. I can't imagine the "precompiled" scripts are so much more readable its worth the incomprehensible mess it appears to generate with the "compiled" script.

Why are people so afraid of Bash?

geocrasher|1 year ago

I have to agree. Bash works fine in its environment, and while there are times when another language might be more appropriate for whatever reason, Bash works. I can run it on any box I have access to and if I stay away from utils that aren't preinstalled, I don't need to worry about dependencies. I've found that python is far more version and dependency driven.

nickm12|1 year ago

I think the use case for this is where you need a bash script on a machine where you can't easily install and maintain a runtime.

thefaux|1 year ago

I sort of get that but does this hypothetical system not have a c compiler? If it does, you can compile and install lua in probably under 5 seconds and actually have a sane language with respectable performance to target.

It also seems odd to me that a place that would be so rigid about installing a tiny language runtime would be ok with checking in the artifact of an experimental programming language.

teo_zero|1 year ago

On a machine where you can't easily install and maintain a runtime but you can install bash and amber and bc and sed?