this post was submitted on 24 Jan 2025
43 points (100.0% liked)

Programming

17941 readers
145 users here now

Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!

Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.

Hope you enjoy the instance!

Rules

Rules

  • Follow the programming.dev instance rules
  • Keep content related to programming in some way
  • If you're posting long videos try to add in some form of tldr for those who don't want to watch videos

Wormhole

Follow the wormhole through a path of communities [email protected]



founded 2 years ago
MODERATORS
 

For those of you unaware: https://nushell.sh/

This is by far the most unique shell out there, since it doesn't use raw text as output/input to command line calls, but instead an actual data structure. It's like if every CLI call returned a database table, in a way.

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 7 points 3 days ago (2 children)

The problem with this is, the standard tools do not output in the format this requires. Windows PowerShell has a similar idea behind it, but at least the system is designed for this in mind. That's why I think its not really worth learning and using Nushell as the default shell. Maybe I'm wrong. Would love to hear why.

[–] brian 8 points 3 days ago (1 children)

worst case you're parsing command output like you would in bash, so you're not really worse off. I've got a handful of aliases that wrap commands I run often so I only dealt with parsing in the beginning. there are enough builtins that output structured data, or applications that have a json flag that it's still useful.

speaking of powershell, it's easy enough in nushell to write an alias that shells out to pwsh and calls ConvertTo-Json then from json on the nu side. that gives you plenty of extra commands that are structured, at least on windows

[–] [email protected] 4 points 3 days ago (2 children)

Why not just use Powershell then? It's been available for Linux for a long time. I use it for scripting quite often

[–] brian 4 points 3 days ago

bc nu does everything pwsh does, but without the odd and verbose syntax. their exceptions and error codes are two different systems and don't make sense by default. instead of making shell cmds easy to parse I find myself having to use dotnet versions of things, which would be fine if the syntax for that wasn't so terrible. nu still feels like a unix shell for the most part.

pwsh has its place, especially since it's default. I've written plenty of pwsh scripts at work for ci and the like. I can get over the verbose naming in a text editor. using it from a repl isn't my favorite experience

[–] Kissaki 2 points 2 days ago

I always had an aversion to PowerShell syntax.

They're certainly both object shells. If you're already familiar with PowerShell, there's probably no reason or need to switch. I'm not familiar with PowerShell enough to identify where else they differ.

[–] Kissaki 2 points 2 days ago* (last edited 2 days ago) (1 children)

What do you mean by standard tools?

I feel like many if not most of what I would consider those are CLI tools other shells require because they themselves do not provide the functionality, whereas Nushell does.

What do you mean by PowerShell is designed with that in mind while Nushell isn't?

[–] [email protected] 1 points 2 days ago (2 children)

The system tools have the output of what PowerShell offers, or doesn't it? I actually don't use Windows. In Linux the standard tools are stuff like grep, i don't know everything in the system is designed with stdin and stdout as lines and similar. Nushell requires the programs to understand Nushell, so its kinda like its enclosed system and not really a Shell in my opinion. It does not integrate (at least in Linux) into the other tools as well. That's why they provide a few extra tools that only work in Nushell.

Not saying this is a bad approach, its just not what I would do.

[–] Kissaki 2 points 2 days ago* (last edited 2 days ago) (1 children)

Nushell requires the programs to understand Nushell

My point was that with Nushell you don't need various command line tools like you do on bash or whatever. The question of whether those integrate well with Nushell doesn't even come up/is not central - although it does work with text just fine.

Nushell integrates very well into various data formats. It can handle text pipelines, but the advantage is in using structured data. You skip the entire text-pipelinie and work on structured data throughout, and don't need grep or awk or find or du or df or whatever cli tools you would use in a simpler/classic Linux shell.

[–] [email protected] 2 points 2 days ago

And my point is, this is not a "real shell", in the sense of "default interactive shell". It is an encapsulated system that works on its own. Basically like a programming language would be (speaking of programming language, there is also one for Python Xonsh). I don't have a problem with this approach though, so don't get me wrong, need to stress this enough. There are many implications here. If one likes this approach of replacing the entire Linux tools stack, its up to them.

However... just like with any other tool, I think Nushell is an excellent "enhancement" or "additional" tool to what I already use. Especially working with structured data can be very useful. Instead parsing the data myself or using other parser tools like jq or Python, Nushell could do this with all the features it provides. Even though I am not for replacing my own shell with this, I need to look closer to have it as an additional tool installed. From that angle, I see Nushell more like a programming language like AWK (yeah its a full language inside, I think Turing complete) or Python. But I'm not sure I really want to, because I like to share my solutions.

[–] [email protected] 2 points 2 days ago

Nushell has a "find" that works just like grep with more features. Not to be confused with findutils. Nushell ships replacements for all the standard tools.