Live data from Hacker News

Ask HN: What to use instead of Bash / Sh for scripting?

news.ycombinator.com

41–50 of 106 posts

Re: Ask HN: What to use instead of Bash / Sh for scripting?

#42

I’ve seen people use Go because it’s a simpler language. It’s what I would probably use if I didn’t want to use bash. What do you think about editing the title to include “for scripting”? I thought you were asking for recommendations like zsh or fish when I first clicked

Also go has the advantage of producing a single static binary. Easy to build on your machine and run on another host.

Which is why I'm writing most of my tooling in Rust.

Deployment or installation is just one scp away.

not rewriting, just when It needs large refactoring, or is currently a mess, or brand new.

Re: Ask HN: What to use instead of Bash / Sh for scripting?

#43
post #42

Earlier quoted context omitted.

Also go has the advantage of producing a single static binary. Easy to build on your machine and run on another host.

Which is why I'm writing most of my tooling in Rust . Deployment or installation is just one scp away. not rewriting, just when It needs large refactoring, or is currently a mess, or brand new.

Assuming you're deploying to the same OS/architecture that you're working from, otherwise you'd have to rebuild (which Rust makes easy to do, but still)

Re: Ask HN: What to use instead of Bash / Sh for scripting?

#45
post #42

Earlier quoted context omitted.

Which is why I'm writing most of my tooling in Rust . Deployment or installation is just one scp away. not rewriting, just when It needs large refactoring, or is currently a mess, or brand new.

Assuming you're deploying to the same OS/architecture that you're working from, otherwise you'd have to rebuild (which Rust makes easy to do, but still)

How easy is it to cross-compile with Rust?

Re: Ask HN: What to use instead of Bash / Sh for scripting?

#46
This won’t work for many people who don’t know the language or its ecosystem, but I’ve started doing my ad-hoc scripting in Rust using rust-script [0]. I’ve got a template with lots of boilerplate for everything I might need and I just copy it and delete the parts I don’t want. Having argument parsing, dotenv init, toml configuration and such ready to go with just a few tweaks, simple user prompting with dialoguer [1] and easy delegation to other tools with cmd_lib [2] means I can often write the tool I’m envisioning in just a couple of minutes.

[0] https://rust-script.org/

[1] https://crates.io/crates/dialoguer

[2] https://crates.io/crates/cmd_lib

Re: Ask HN: What to use instead of Bash / Sh for scripting?

#47

Earlier quoted context omitted.

Powershell is a horror you mean, it's got the verbosity of objective c with the consistency that comes with all Microsoft designed products. Just use a proper scripting language.

No, I said what I mean. Bash and its disasters like [ as executable and mega error prone and awkward language designed 50 years ago IS horror. Verbosity of powershell is optional, I don't use it. > consistency that comes with all Microsoft designed products. Oh, lets not troll here.

> its disasters like [ as executable

Why is that a disaster? What problem has it caused you that wouldn't have happened if it wasn't an executable?

[[ is a non-executable version of [. Does that solve your problem?

Re: Ask HN: What to use instead of Bash / Sh for scripting?

#48
Can you be more specific than "fatigue"? That sounds like ennui, in which case maybe consider a job switch instead of a language switch (not being sarcastic or intentionally mean). Bash plus all the Unix tools (awk, grep, sed, tsort, comm, the ones I don't know, etc.) have pretty long legs, in terms of functionality and the syntax is pretty understandable. They provide most of what Perl offers, apart from OO (-ish) and line noise.

If you want strong typing (are you scripting in the large?), then, almost by definition, no scripting language provides that. If you need performance, switch to a compiled language (or a jit-compiled interpreted language) that most of your co-workers understand.

If Python brings too many dependencies, I guess you're trying to do something that is way out of the realm of possibility for bash, so you're not looking for an "alternative" to bash, you're looking for the best language for whatever project you're undertaking. And you may not be able to get away from the dependencies if you're trying something specific/sophisticated.

Re: Ask HN: What to use instead of Bash / Sh for scripting?

#49
post #47

Earlier quoted context omitted.

No, I said what I mean. Bash and its disasters like [ as executable and mega error prone and awkward language designed 50 years ago IS horror. Verbosity of powershell is optional, I don't use it. > consistency that comes with all Microsoft designed products. Oh, lets not troll here.

> its disasters like [ as executable Why is that a disaster? What problem has it caused you that wouldn't have happened if it wasn't an executable? [[ is a non-executable version of [. Does that solve your problem?

I don't have a problem - I don't use bash unless its few lines or absolute must.

Its disaster because launching process to achieve simple math expression is just ridiculous, besides being slow and besides having to terminate it with ;. Its wrong on so many levels I don't even know where to start, they must have been smoking some nasty things back in time.

Post reply on HN