DEV Community

Cover image for Bash is a terrible as a programming language, but what's the alternative ?

Bash is a terrible as a programming language, but what's the alternative ?

Jean-Michel 🕵🏻‍♂️ Fayard on February 16, 2024

I believe in self-compassion so I have a personal rule Never write a shell script that is more than 5 lines long. Let's bash Bash I ...
Collapse
 
fyodorio profile image
Fyodor

I used to engaging Node for that. You basically need only Node (which can be installed through nvm at any env via a bare curl call or something). Rich and beautiful NPM ecosystem is at your disposal. Further convenience is the matter of efforts.

But thanks for the V reference, looks interesting.

Collapse
 
cogwizzle profile image
Joe Fehrman

If you like to use JavaScript for shells I think you would like this. github.com/google/zx

I find it easier than using the build in node process utils.

Collapse
 
jmfayard profile image
Jean-Michel 🕵🏻‍♂️ Fayard

I tried zx, that looks really nice thanks !

Collapse
 
zabjd22 profile image
Zetrax

no one told me this exists, such a shame 🙏

Collapse
 
jmfayard profile image
Jean-Michel 🕵🏻‍♂️ Fayard

My issue is that I know the language but not the ecosystem. Browsing npmjs.org is overwhelming.
What kind of npm libraries would you use for the common tasks someone need for a CLI tool ?

Collapse
 
fyodorio profile image
Fyodor

Usually, in addition to the standard integrated Node tools, you would need something like path and child_process (or execa), that could be enough for simple stuff and working with files and trivial scenarios. If you need some nice decoration (for a team, or for pleasing yourself 😅), there are listr, inquirer, chalk, and figlet. There's much more to that, even CLI frameworks, but I prefer simpler and more granular tools.

Collapse
 
ben profile image
Ben Halpern

I find the bigger issue ends up being the sharability.

The problem with any platform is that the further you get from the thing that ships to everyone, the less you can confidently have in common with everyone else.

That's so much of the power of bash, git, etc.

Thread Thread
 
jmfayard profile image
Jean-Michel 🕵🏻‍♂️ Fayard

I strongly agree, distribution is key !

It doesn't have to be bash though, if the thing is easy to bootstrap & index via npm, brew or something, I am all for it.

Collapse
 
mistval profile image
Randall

I do basically the same. Most of the bash scripts I write just invoke node to do the heavy lifting.

Collapse
 
jmfayard profile image
Jean-Michel 🕵🏻‍♂️ Fayard

When I say that bash is bad, I mean shells in general.
They are good for sysadmin tasks, when what I am doing is one program being executed after another.

But I pause and reflect as soon as I find myself using functions / if else / for loops / arguments / ...

Collapse
 
jmfayard profile image
Jean-Michel 🕵🏻‍♂️ Fayard • Edited

language = V

The idea comes from a discussion about V, a modern programming language that on paper seems almost too good to be true.

Image description

My obvious counter-argument is : why would I invest my time learning a langauge that just reached version 0.4 ?

But then I saw this

Cross-platform shell scripts in V
V can be used as an alternative to Bash to write deployment scripts, build scripts, etc. The advantage of using V for this is the simplicity and predictability of the language, and cross-platform support. "V scripts" run on Unix-like systems as well as on Windows.
V is 80% go and can be learned in a week-end.

Ok, fair enough, I would rather spend a week-end learning V than fighting to debug a dumb Bash script, that sounds appealing to me.

Collapse
 
tgkprog profile image
Tushar Kapila

A weekend to get an intro. More tobe good

Collapse
 
jmfayard profile image
Jean-Michel 🕵🏻‍♂️ Fayard

This is probably assuming you are somewhat familiar with go

Collapse
 
autra profile image
Augustin Trancart

Yes for simple scripts, it's enough. Although you are comparing apples to orange, because you can call rsync in one line in python code too ;-) (well, with the import, probably 2 or 3 but well).

My problems with bash:

  • you cannot really unit test it (and yes, I have tested bats)
  • there several ways to do "if", each with their caveats and pitfalls
  • there is no real exception handling
  • there is no real functions (they are commands) and you cannot really return from them (return statement is for error code, anything other than indicating an error is a hack and will bite you)
  • argument parsing is an horror

For these reasons, anything other than trivial is really cumbersome with bash. Especially, as soon as we have arguments to a script, we should just use python and argparse for instance.

Collapse
 
ddebajyati profile image
Debajyati Dey

Damn! I laughed sooo hard! Reaallly agree on the last point. Argument parsing is hell of a nightmare in Bash.

Collapse
 
russellbateman profile image
Russell Bateman • Edited

I have written installation scripts in Bourne (yeah, that's sh) totally 10s of 1000s of lines of code. (Because across many, varied systems where even bash wasn't a common denominator.) Very excruciating, although this was 20 years ago and there was no debugger. Obviously, I created "libraries" and other helps, but I would have preferred Python.

Collapse
 
togakangaroo profile image
George Mauer

Powershell is an excellently designed language which did the hard work formalizing lessons learned from bash's awfulness.

But realistically what I see emerging in the next few years, is not yet another command line scripting language. I would be pretty surprised if non-scripted interaction with the CLI in 5 years still requires people manually typing out well formatted commands piping things between utilities. I already ask chatGPT for half of the things I want to do with the CLI, I'm not sure what's to stop that from becoming much more prevalent.

For scripting in the meantime, python or powershell or another omnipresent alternative will be fine

Collapse
 
hlship profile image
Howard M. Lewis Ship

Babashka (github.com/babashka/babashka) allows me to have my cake (write scripts in Clojure) and eat it too (fast! startup). Having a fully powered language to write even simple things in (because they never stay simple) is near ideal.

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

I honestly believe .*sh are an amazing family of domain-specific scripting languages, and this specialisation also makes them utterly terrible outside their domain.

If what you want consists mainly in 1. running executables 2. managing their I/O then all the best tools for that job will likely be languages you wouldn't want to write an HTTP server in, and that's not a problem.

Collapse
 
arcanjoaq profile image
arcanjoaq

language = Clojure (with Babashka)

It has a really fast start up due to the GraalVM. 😁

Collapse
 
eric_stewart_6c37bebed155 profile image
Eric Stewart

This is the answer

Collapse
 
nova38 profile image
Thomas N Atkins

Python is great for some stuff, but to replace lot of the stuff you would use bash for powershell is one of the best scripting languages I have used. Its not perfect but it produces a lot more readable scripts and it is a lot easier to find the utility function you need because of the verb-noun syntax. (Plus it is also cross platform)

Collapse
 
ingosteinke profile image
Ingo Steinke, web developer • Edited

One of the problems making bash hard to learn is that some commands consist of special characters, so you can't even google the correct syntax. Its compactness makes it hard to read and easy to get things wrong.

Another thing is that "bash" is not only bash, but bash plus a set of UNIX tools that we will have to use anyway, with or without additional wrapper functions around them.

There are bash built-ins that differ between shells, as many users found out when some sophisticated bash scripts stopped working on Linux machines, after Ubuntu had decided to replace bash with the more minimal dash shell by default.

I used to code Perl for web development long time ago, and maybe Perl is still a valid choice for administrative tools beyond simple bash tasks. But I also see many Python scripts used instead, so maybe we should all learn Python.

But as ECMAScript/JavaScript/TypeScript already seems to run 90% of everything that I use as a web developer, why not use node/deno for local administration as well?

Collapse
 
jmfayard profile image
Jean-Michel 🕵🏻‍♂️ Fayard • Edited

language = Kotlin

Two options :

  1. Lightweights Kotlin scripts are a thing
  2. A full Kotlin project compiled to a binary executable with Kotlin native

I liked the idea of it, but right now Kotlin scripts are very niche and not quite supported.
The native toolchain is quite heavy, the compiler is slow.
Packaging is not really ready.

So right now it's better in theory than in practice, probably use something else.

Collapse
 
strottos profile image
Steven Trotter

Agree with this completely. I genuinely think PowerShell is an overall improvement but there's still so much that annoys me about it.

Whenever people offer things like zsh, fish, etc that's like putting a sticky plaster on a broken arm. It might be a bit better but it's still building on something fundamentally broken.

I also think that bash has a lot of people stuck in Stockholm syndrome, because it's great at some things people love everything it does, but everything you say is true.

I big time think there's a market for a modern decent shell but also appreciate this is genuinely hard.

Great article 👏

Collapse
 
farrellit profile image
Dan Farrell

Totally agree. Shell scripting is deceptively difficult. The syntax is arcane and handling of error conditions complex. One of its only positive is being nearly ubiquitous, but so much functionality is left to other programs you still don't have a very consistent runtime environment.

Collapse
 
thomaslevesque profile image
Thomas Levesque • Edited

Bash is a terrible language, I won't argue with you about that. However I don't think it's the worst. Batch files on Windows are much, much worse.
I tend to use Powershell now, both on Windows and Linux. It's not perfect, but it's okayish.

Collapse
 
mindplay profile image
Rasmus Schultz

vlang.io might be interesting as a replacement - small, simple, ships as a single executable, has most of the things you need from bash, and is much easier to learn.

Collapse
 
moopet profile image
Ben Sinclair

I kind of agree, in that I think if there's anything you need to code more than a very simple for loop then you would be better off using any available scripting language.

Having said that, I write a lot of shell scripts. I try to make them POSIX if at all possible, and that's kind of my cut-off point for choosing a different language. If you need to use a bash extension for arithmetic then either fall back on bc or make the jump to Python or whatever.

... but there's no point in using Python if the majority of what you're doing could be accomplished by calling grep in a subshell.

Collapse
 
jizusun profile image
Jizu Sun

If you know some JavaScript, maybe try github.com/google/zx

Collapse
 
k1lgor profile image
k1lgor

I'm disagree with all of you who thinks bash is bad or hard to learn. I am using both, Bash and Python, for over 3 years and maybe more and in some cases I prefer Bash over Python because would easier to write it in Bash and the performance would be slight better than Python. Try comparing Vim or Lua scripting to Bash and you'll realise how easy to learn is Bash.

Collapse
 
eduardopazz profile image
Edu Paz

Bash is hard to learn, period. If it was easy, there would be few people complaining about it. If it's famous for being hard to learn, it's hard to learn. It's not about opinion.

Collapse
 
k1lgor profile image
k1lgor

If Bash is hard to learn... Have you opened a Linux distro ever or some Unix at all? If you think Bash is so hard to learn, I can imagine your opinion about Rust, C++, C, etc.

Thread Thread
 
eduardopazz profile image
Edu Paz

I've been using Unix since 2016 (i guess). Started with Linux due to a crappy notebook that couldn't run windows with 1.6gb of RAM.

Then switched to MacOS in 2021.

Just because you know something that other people often complaint it's difficult, it doesn't make that something less difficult.

It's not about opinion, it's facts. If these tools weren't hard, they wouldn't be famous for being hard!

I see no one complaining Python is hard, for instance, because it isn't!! Compared to Bash or C, of course.

Collapse
 
mechrisreed profile image
Chris Reed

Until reading this post, I had never heard anyone say bash was hard to learn. I've been writing software for 18 years.

Thread Thread
 
jmfayard profile image
Jean-Michel 🕵🏻‍♂️ Fayard • Edited

Learning is not the issue, debugging is the issue.

I don't know how many times I have written shell scripts that worked until someone use a file that has a space in it, or something equally stupid...

It's like YAML where you have everything working and then the world falls apart because you have added a space.

And there is this feeling that it will never get better, I did the same kind of mistakes 20 years ago

Apparently OPS people are good at that, but I have PTSD

Thread Thread
 
mechrisreed profile image
Chris Reed

bashdb.sourceforge.net/

It is just like debugging anything else

Collapse
 
platoxia profile image
Platoxia • Edited

Every Bash bashing post has one thing in common; they ignore the fact that the Bash programming language features are meant to facilitate its purpose as a command interpreter, rather than as a general-purpose, interpreted programming language.

As per the Bash Info manual:

As a command interpreter, the shell provides the user interface to the rich set of GNU utilities. The programming language features allow these utilities to be combined.

If you don't spend a lot of time on the command line using Bash as a command interpreter for other programs/utilities while using anonymous pipes (or any other Unix IPC) for message passing, then maybe you don't need its programming language features anyways. Most people can get by with the built-in facilities Bash provides, along with simple sed, grep, awk, or perl one-liners without having to delve too deep.

Bash, like all shells, is largely misunderstood by those who complain that the programming features are bad, or don't work as expected, or are inefficient as compared to general-purpose, interpreted programming languages, while completely missing the point.

If you work on a Unix -like system to get real work done, properly knowing Bash, or any other shell, along with the built-in Unix IPC mechanisms and all the *utils suits (coreutils, binutils, util-linux, etc...) is almost a panacea. But, but, but...Bash doesn't have any data-structures and Bash arrays suck! Have you tried recutils?

Bash on its own isn't a panacea. Its the collection of tools that make Unix-like systems so powerful. If you want to take advantage of full power of Bash, you have to learn all the other parts that go with it. Only then will you understand the foolishness of comparing Bash to any general purpose, interpreted programming languages. They are not the same thing at all.

Collapse
 
iseiryu profile image
Sergey

IMO Bash is a weak command interpreter. I got comfortable with it over the years and can read the man pages when needed. It's still a terrible experience that we, as the developer community, should push to improve.

There are no common bash/sh standards across multiple utilities, built-in facilities, different OSs. Utilities and their flags are named with "I feel like this letter today" approach. They mean different things on different operating systems. You need a lot of utilities and curl/wget/apt-get commands to add them (even for jq) to do any more or less serious setup on a medium-large project.

My choice is pwsh. It's easy to install on all major OSs. It's very well documented and the documentation is in a single place. It has clear flag names. It has text parsers for JSON, CSV, XML, HTML and other formats out of the box. It can connect to DBs out of the box. It has full access to the whole dotnet framework (gazillion of features). It's a first class citizen on Azure.

learn.microsoft.com/en-us/powershell/

Collapse
 
platoxia profile image
Platoxia

I'd like to preface this by saying that I am not proselytizing Bash, Unix, etc, or trying to disparage other systems or projects. That said, It seems like what you are comparing are disparate systems.

Bash, while POSIX compliant, is part of the GNU project, with tools that have many extensions on top of POSIX. Other similar projects have done the same and the extensions, of course, cannot be expected to all have the same command line switches since, as you say, there is no common standard beyond POSIX.

That said, the GNU project certainly has made attempts to standardize the command line switches among all the individual tools within their own project by adding long-options, while the short options that emulate the original Unix tools are the same as would be expected by the original tools, AFAIK.

What you describe as cohesiveness among the Microsoft tools should be expected by any project, and is largely true for all of them, respectively.

The inconsistencies you mention are mostly the result of disparate projects that have provided extensions to the POSIX standards.

I may be wrong about any of this, as I am not an expert historian of technology, and please correct me if I am. This is my understanding of the differences you mentioned.

Thread Thread
 
iseiryu profile image
Sergey

I understand the historical reasons but it doesn't eliminate the fact that bash is a lot harder to learn and to maintain than pwsh once scripts get passed simple cd, ls, cat stuff.

Collapse
 
ajborla profile image
Anthony J. Borla

Your response is eloquent, and I am in complete agreement with the sentiments expressed. Your final paragraph, in particular, adds a much needed context to this discussion.

Collapse
 
cogwizzle profile image
Joe Fehrman

Claiming a language is bad because you can't remember the syntax is a skill issue.

Bash has a dependency management through brew or apt or whatever other stores you use.

Force yourself to solve problems with it and you will see immediately there is some value.

Every language has its quirks.

I've seen just as many criticisms of JavaScript or PHP. All programming languages have trade offs.

Collapse
 
instalab profile image
Samuel Boczek

On one hand you have people complaining "PHP is not a real language", on the other hand you have people actually being productive and creating Wordpress, Laravel, Symfony or even the 4 million lines monster of an e-commerce software "Magento"

Collapse
 
bahner profile image
Lars Bahner

Why hate on bash. I can do 95% of all my work in bash. Sometimes you need a little go, erlang or python. Maybe you're just overthinking and engineering the solutions? 5 liners sounds like bad scripts. Even the small simple ones I write are around 100 lines. With individual "functions", error message, usage and argparsing. I've written scripts a decade ago that are still running just fine. And, honestly, I'm not a very clever programmer, just mind my T's and I's.

KISS!

Collapse
 
jmfayard profile image
Jean-Michel 🕵🏻‍♂️ Fayard

I have PTSD of trying to write complex bash scripts :)

Collapse
 
iseiryu profile image
Sergey

Writing is one thing. Try supporting a bash script for several years with constantly changing requirements.

Collapse
 
dasfluchen profile image
DasFluchen

Am I missing something here or are you referring to something other than the UNIX SHELL?

I have to laugh at you modern-day warriors whining about something that's probably older than most of you. Personally, I've always used C shell but that's just 1 old man's opinion. Until you've debugged memory allocation issues with DBX, please with your outrage! It's petty!

Your answer might be PERL. It's your basic C or PHP syntax and is powerful enough to 86 SED and AWK via a single command. If you're complaining about the limited time when you use BASH with your repo check-ins, please write a COBOL program to calculate the compound interest of a 30-year mortgage. No, please do .. your head will explode!

Collapse
 
eduardopazz profile image
Comment marked as low quality/non-constructive by the community. View Code of Conduct
Edu Paz

cringe

"hey, look how I'm old and used to old tools, you kids are dumb, don't know what is really hard" 🧓🧓

Collapse
 
dasfluchen profile image
DasFluchen

Listen up Paz of Shi† Maybe you should show your elders a bit of respect. Notice the word *"opinion" * ... meaning my perspective and view. If you disagree then just move along ... save your trolling for FaceTokagram!

Here's what you need to take away from my first comment ... it's not a programming language it's a SHELL!!! Stop talking like you know something because you're just embarrassing yourself! Almost as much as the dirt on your face you call a mustache

Collapse
 
palexdev profile image
Alessadro Parisi • Edited

This.
I have a Java project and I needed some scripts to update and process some resources. Since I wanted them to be executable on any OS I made these choices:
1) the tools responsible for the update/processing come from npm and they are cli tools
2) the scripts had to be written in bash because it was the only one language I could execute on any OS (given than on Windows I need the Git shell anyway)

It was a nightmare. Loops and conditions are so counterintuitive sometimes, and let's not talk about variables...
I ended up rewriting them in Groovy, while still using npm cli tools though

Collapse
 
hijazi profile image
Baha

I totally agree, I have read once that if your bash script is 100+ lines then it should be python.
However under 100 lines, Bash feels like a linux super power. To be able to use the linux commands like this, and yeah and I definitely won't try to use it as general purpose programming language.

Collapse
 
autra profile image
Augustin Trancart

I'd put the limit to either one of these conditions:

  • 50 lines
  • you need arguments to your scripts
  • you have to test more than trivial stuffs
Collapse
 
jmfayard profile image
Jean-Michel 🕵🏻‍♂️ Fayard

I would say that Bash initially feels like a super power
And then it quickly feels like I have shoot myself in the feet

Collapse
 
efpage profile image
Eckehard

Most regular programming languages provide an option to execute shell commands, so, why don´t you not use any of them to do the things you regularly woud do with a shell script? As long as you do not need an UI or complex interactions, things are not much different from writing scripts.

Collapse
 
jmfayard profile image
Jean-Michel 🕵🏻‍♂️ Fayard

Yes, but with which ones ?
Some programming languages are better at replacing Bash than others

After the discussion I would bet on JavaScript with zx, Python, Go, V

Collapse
 
efpage profile image
Eckehard

Seems a good choice, maybe you should add Rust? I do not think the language matters too much. Just try to use the language that you know best.

Collapse
 
dexter38 profile image
Pascal Gautherot

I use Ruby. Very funny language, full object, near human language.

Collapse
 
referefref profile image
ref

As someone who has written an entire CMS in bash for kicks I disagree, the simplicity and power of native C applications make bash a great easy grab tool for prototyping. With zsh coproc it borders on useful, and in many cases is faster than python. But if I'm serious I'll reach for golang

Collapse
 
jmfayard profile image
Jean-Michel 🕵🏻‍♂️ Fayard

I will admit, that's a nice challenge ah ah

Collapse
 
trevorbenson profile image
illuminatus • Edited

While aliases are probably more common, Bash does have functions, but maybe not what you consider a "real function"? Also variable substrings being built in, as well as index and associative arrays. However, I also like the 5 line rule, although I'll admit my limit is probably closer to 15, +/-5.

That said I also try to avoid Bash scripting even before that limit. While I dable in JavaScript, Typescript, Node and Rust, I actually try to use Python as soon as possible. I find it elegant and simple compared to most languages. Even though it's dynamic, Typing can be achieved in a number of ways. Unit tests are pretty simple to achieve as well. As for package management I use pipenv when I want a unique venv which doesn't taint my git repo or require .gitignore or .git/info/exclude entries, plus it provides a nice way to lock versions as well as define actual requirements separate than those just for development (unit testing etc.) and then generate a requirements.txt file to be included in the repository.

When it comes to something where performance is a concern I see if compiling my Python script via codon into native machine code is viable. When it works it can beat the pants off C++ and many other languages. This is also becoming simpler to do with Codon creating native versions (ports?) of modules as well as supporting imports for many of the native Python modules too. I only hope they keep picking up speed on creating new releases to continually make it easier to compile and reduce the performance gap between Python and most other languages.

Collapse
 
elsyng profile image
Ellis

Bash is not a programming language as such. It has a context, it has a purpose, it is specific and useful within that. Like each and every other tool. Use the right tool for the right job. Bash mainly operates on the file system and programs level: it typically starts programs to run operations on files, and it can facilitate the data flow between these programs. It's job is not: doing the tasks those specific programs do.

If you need to do some complex text parsing, process large amounts of data quickly, or other specific tasks, you don't choose Bash for that. If you do, that's on you ;)

As the famous quote goes: if you judge a fish by its ability to climb a tree ...

Collapse
 
instalab profile image
Samuel Boczek

The fact that you have to refer to the documentation, every time you want to write a simple statement, says more about you than the language. That being said, if you want something that is easy to distribute and a "proper programming language" look no further than Perl - the runtime is available on most systems out of the box. Alternatively, you can do python, is very easy to setup and a lot of software already depends on the runtime so telling someone "you need to install python to run this script" sounds less weird than "you need to install node" 😉.

Collapse
 
jmfayard profile image
Jean-Michel 🕵🏻‍♂️ Fayard

I don't put my ego into my ability to remember arcane syntax and command line arguments but if that makes you feel smarter, go for it

Collapse
 
rawsp33d profile image
Ross Hadden

I use nushell for my shell and scripting at this point (aside from scripts I make for work with the intent of others using or seeing and whatnot). After more than a decade of refusing to use anything that wasn't bash because it's omnipresent, I finally caved and regret not doing so sooner.

Collapse
 
hstsethi profile image
HstSethi

I agree with everything you said here. Another thing I hate about Bash is that it lacks even basic string manipulation features.

It depends on external programs like sed, grep, AWK, to do even simple things. Not only the output of such programs is hard to parse, but the cost associated with creating each process.

Collapse
 
jblaschke profile image
Johannes Blaschke • Edited

I use Lua and a module that I developed to handle any process execution (and interaction with the os): luarocks.org/modules/johannesblasc...

Why Lua? It's small enough to install anywhere, and sufficiently feature rich to do everything that you'd use bash for (automating system administration mainly).

Collapse
 
leewiscovitch profile image
Lee Wiscovitch

Just to be clear, and I think others have mentioned this, but bash isn't a programming language...it's a scripting language. Two vastly different domains...Python kinda straddles that but usually it's a clear deviation between the two. You wouldn't use bash to provide a complex gui, and you wouldn't use C to copy some files...You can, but that's on you then ;)

Collapse
 
nylar357 profile image
CͨoͦNᴛⷮRͬAͣ

Couldn't agree more bash has its place and it's extremely good in that place. It's easy to pick up and useful for specific jobs.

Collapse
 
lostcitizen profile image
lostcitizen

bash has been around +20y for a reason.

Collapse
 
jmfayard profile image
Jean-Michel 🕵🏻‍♂️ Fayard • Edited

The same can be said for CMD, and the reason is that because it's installed by default

Collapse
 
edtechrsa profile image
EDTECH RSA • Edited

Bash is an alternative way to push and pull to GitHub. Git was invented before GitHub. It’s not a programming language it’s Shell Scripting. We learn about the Linux Kernel and the Shell. This is basic knowledge if we respect Linus Torvalds as the father of the Linux kernel.

Collapse
 
daveparr profile image
Dave Parr

GitHub logo nushell / nushell

A new type of shell

Nushell

Crates.io Build Status Nightly Build Discord The Changelog #363 @nu_shell GitHub commit activity GitHub contributors

A new type of shell.

Example of nushell

Table of Contents

Status

This project has reached a minimum-viable-product level of quality. Many people use it as their daily driver, but it may be unstable for some commands. Nu's design is subject to change as it matures.

Learning About Nu

The Nushell book is the primary source of Nushell documentation. You can find a full list of Nu commands in the book, and we have many examples of using Nu in our cookbook.

We're also active on Discord and Twitter; come and chat with us!

Installation

To quickly install Nu:

# Linux and macOS
brew install nushell
# Windows
winget install nushell
Enter fullscreen mode Exit fullscreen mode

To use Nu in GitHub Action, check setup-nu for more detail.

Detailed installation instructions can be found in the installation chapter

Collapse
 
steveja profile image
Steve Alexander • Edited

Yes, bash has poor syntax, semantics and the uncontrollable multi-layer evaluation/expansion scheme makes quoting & analyzing scripts a nightmare. But suggesting 'use Python' is a non-starter as it fails to address the intent of a shell.

The purpose of a shell is to allow a user to 'exec' processes with set of arguments, and to 'connect' that process to others so that interaction is possible. For convenience bash performs wildcard expansions of file names, allows various redirections of stdin/out/err (and more), some basic signal handling, performs a little math (awkwardly). Can do a little boolean logic based on things like return codes and file features. It can iterate over numerical indices or string tokens (inflexibly).

Any programming language that intends to replace bash must include this sort functionality; hopefully with much cleaner syntax & semantics.

Collapse
 
gregorweertman profile image
Gregor-Weertman

You need a language that every decent Linux administrator knows in order to have continuously.
That is bash.
Use perl, python or another language and almost no administrator can read it.
Even the bash scripts shouldn't be too complicated.

Collapse
 
shekharrr profile image
Shekhar Rajput

Bash is not terrible in itself. It might not be good outside the core linux.

Collapse
 
nafg profile image
nafg

Fish shell, otherwise Scala script

Collapse
 
nash_oudha_ce4cb28640e003 profile image
Nash Oudha

I think you are stuck in your developer bubble, bash was never meant to be a programming language, it is meant to be a lean scripting language inspired ny C to do day to day admin task.

Collapse
 
iseiryu profile image
Sergey

bash sucks at scripting though and that's a problem.

Collapse
 
gresco profile image
Greg Martin

No

Collapse
 
devsrnotops profile image
Ryan Waldron

Bash is not a programming language, it is an ops scripting language. All you devs go write code and let the ops folks get on with making a secure resilient place to host your work properly.

Collapse
 
david_j_eddy profile image
David J Eddy

This Oz the same problem JS/Ecma has. There is no valid replacement for the role or fills. Not worth the install base now, now or ever.

Collapse
 
jeklah profile image
Jeklah

Zsh

Collapse
 
flavius profile image
Flavius Aspra

Xonsh

Collapse
 
luisdavim profile image
Luis Davim
Collapse
 
raphaelcarlosr profile image
raphaelcarlosr.dev

I agree that bash and shell are languages ​​with a steep learning curve, but they are widely supported, and despite not having OOP, they do support functions, streams, etc.

Collapse
 
n451m profile image
n451m

Bash leans more towards scripting and heavy overkill if you program. You can script with most languages but bash is less intensive and has gentle learning curve for uber *NIXers.

Collapse
 
iseiryu profile image
Sergey
Collapse
 
aturki profile image
Ali Turki

What about fish ? fishshell.com/

Collapse
 
eduardopazz profile image
Edu Paz

Unfortunately not posix compliant

Collapse
 
scarylerie profile image
ScaryLerie

I guess I'm confused, I thought bash was a scripting language..

Collapse
 
jmfayard profile image
Jean-Michel 🕵🏻‍♂️ Fayard
Collapse
 
steveja profile image
Steve Alexander

Disagree. rsync binary does the glob'ing *& looping, not the shell. Bashmerely collects the two string arguments and performs a fork/exec of rsync.

Collapse
 
benuuts profile image
Ben

I think the best alternative is to script using yaml files 🤓

Collapse
 
jmfayard profile image
Jean-Michel 🕵🏻‍♂️ Fayard

never ah ah