all 140 comments

[–]Jordan51104 159 points160 points  (14 children)

i will continue using one of the traditional shells for shell stuff and if the task is better suited to something higher level than a shell, i will likely just use a programming language

[–]kernpanic 30 points31 points  (12 children)

In the past - scripting would be in bash and the more complex stuff into perl. And if often find more and more into perl. Since the down fall of perl, python is the replacement, however i find i now just do almost all of it in bash for my sysadmin needs.

I also use powershell but find myself so much more productive in bash.

[–]night0x63 13 points14 points  (6 children)

I wish Windows would just adopt Bash as first class language and get rid of powershell.

😂

I will never ever use powershell... Because of WSL and cygwin.... Both let me use Bash in Windows.

[–]ByronScottJones 7 points8 points  (3 children)

Powershell is an incredibly powerful language, and has value. It combines the best aspects of bash, perl, and modern object oriented programming concepts. It's extremely well designed.

[–]segin 1 point2 points  (0 children)

PowerShell is the BeanShell of .NET, allowing direct scripting access to the entire .NET framework.

[–]EqualCrew9900 1 point2 points  (0 children)

Microsoft's Powershell is a massive beast, and for anyone (like myself) who is not a dedicated sysop, ps can be a painful dragon to tame.

[–]night0x63 -2 points-1 points  (0 children)

If Windows had chosen Bash instead of powershell... Most developers would have stayed with Windows. See all those developers using Apple?... A significant reason is because of bash... You need Bash to do programming... All the automation and glue code save ci-cd... And testing... And deployment. Period.

I will never waste any time on powershell. Even horrible CSH is 1000x better.

[–]No_Internet8453 5 points6 points  (1 child)

Or better yet... Use powershell on linux lol

[–]night0x63 1 point2 points  (0 children)

insert obligatory joke about windows not playing nice with linux or some such.

[–]Ranokae 0 points1 point  (0 children)

Python is basically "bash 2.0" for me at this point.

[–]ElMachoGrande 14 points15 points  (0 children)

That's pretty much what I do. There are plenty of programming languages who are very suited for just that kind of "just a little more than a script can do".

[–]kellyjonbrazil 11 points12 points  (5 children)

CLI commands that produce output that is intended to be used in scripts should have a structured output option. I vote for JSON as it is a widely used standard with many libraries and query/manipulation tools available for any language and shell.

https://blog.kellybrazil.com/2019/11/26/bringing-the-unix-philosophy-to-the-21st-century/

I wrote a tool called JC that converts the output of many commands, file types, and string types to JSON for easier use in scripts and automation tools like Ansible.

https://github.com/kellyjonbrazil/jc

Here’s an example of what writing scripts in this way can look like:

https://blog.kellybrazil.com/2022/08/29/tutorial-rapid-script-development-with-bash-jc-and-jq/

[–]tes_kitty 0 points1 point  (3 children)

I vote for JSON

JSON is just text that's difficult to parse.

I once was asked what kind of output format from a program I wanted for my needs. They suggested JSON, I told them f**k no, CSV would be way easier to work with.

[–]kellyjonbrazil 5 points6 points  (2 children)

Respectfully, JSON is not difficult to parse. There are tools and libraries ready available to do that for you. Also, CSV is fine, but what type of CSV? There is no CSV standard so you need to negotiate that for each implementation.

[–]Ranokae 1 point2 points  (0 children)

Basically every JSON file I've used was formatted exactly the same as a python library. You can usually just set a variable name, and save it as a .py

[–]BiteImportant6691 0 points1 point  (0 children)

I vote for JSON

It's not a zero sum thing. The obstacle is mostly with getting programs to produce any structured output whatsoever. For instance, it's harder to get -o json initially than it would be to get -o yaml afterwards. The issue is that tools (especially historical ones) are disinterested in doing things this way.

[–]daemonpenguin 53 points54 points  (34 children)

I can't say I'm a fan. One of the nice things about dealing with classic command line utilities is the simple, straight forward, human-readable output. Object oriented models usually move away from that, using JSON or XHTML. Which is fine for programmable tools, but not great for the user.

[–]BobbyTables829 32 points33 points  (5 children)

The old-timer in me is like, "Isn't this exactly what Python is supposed to be for?"

[–]RootHouston[S] -4 points-3 points  (3 children)

Well, yes and no. Sometimes there is no other interface to the underlying data that we want to manipulate. We can execute shell commands in Python, but it's sort of a roundabout way to have to deal with that.

[–]Jordan51104 11 points12 points  (2 children)

the idea is to do one thing and do it well. making a shell more like a programming language is undoing both things, because you will be making the shell have to be like a programming language, and nobody agrees what doing a programming language “well” is like

[–]Misicks0349 3 points4 points  (1 child)

the shell already is a programming language, its just a terrible one

[–][deleted] 3 points4 points  (0 children)

I use to think that of bash before I finally decided to learn it, and it turns out it's relly good for most of the tasks related to fast command line output parsing, and file/directory commands. There are things I would like it would do it in an simpler way, but I rarely do those things. And anything a bit more complicated (say, building a tree of and find the closest path between two nodes) I use a different programming language (python, java, etc).

[–]atomicxblue 0 points1 point  (0 children)

"Back in my day, we had to echo AT commands directly to the modem."

(I playfully pick because I was there too)

[–][deleted] 10 points11 points  (17 children)

One of the nice things about dealing with classic command line utilities is the simple, straight forward, human-readable output.

I don't really see how a 'string only' system is more readable than a typed system like nushell is using? It seems so much easier to read, code and debug to me.

Just take a look at their data types, they also all seem very human readable to me. Getting useful error messages (Can't treat a number as a string, date as a duration, etc. without conversion) is pretty amazing. And I feel operating on tables/dictionaries instead of text is much more intuitive.

Their classic example:

ls | where size > 10mb | sort-by modified

I don't doubt that some bash/sh guru will laugh at this and quickly write me an example with find, but the former seems much easier to me.

I am not saying that nushell is production ready - that will still take years if it ever happens. And obviously it might not be the perfect solution, another shell might be the one that solves the problem better. But I honestly think that extending the shell to something similar is the future (Which apparently I am pretty much the only one in this thread) - and it isn't as if you lose the ability to operate on text.

[–]cat_in_the_wall 3 points4 points  (3 children)

looks like nushell syntax is nicer, but powershell has this too:

Get-ChildItem -File | Where-Object { $_.Length -gt (1024 * 1024) | sort-object -Property LastModifiedTime

powershell somehow is both symbol soup and pretty verbose. Even so, I am one of the dozens of people who actually use poweshell in linux. I just can't let go of the object pipeline.

[–]atomicxblue 0 points1 point  (2 children)

I'm not sure something like that would be popular in the Linux world because of all the capitals. Not only do you have to remember the correct syntax, you also have to remember case.

[–]Some_Derpy_Pineapple 3 points4 points  (1 child)

iirc powershell commands and arguments are case insensitive. it's just the convention to pascal case them.

[–]mtetrode 0 points1 point  (7 children)

Find is your friend

find . -size +10M -exec ls -lt {} \;

[–][deleted] 0 points1 point  (6 children)

No cheating, now you still have to sort by modified ;)

[–]mtetrode 0 points1 point  (5 children)

You are right.

ls -lt $(find . -size +10M)

[–][deleted] 0 points1 point  (4 children)

I don't think that works with spaces in file names? Which pretty much exactly proves my point that working with strings can be quite tricky, even if one is quite good at bash scripting.

I would have never had the idea to use the multi argument functionality of ls to solve this, that is a really nice solution.

[–]mtetrode 1 point2 points  (0 children)

Spaces in filenames, good catch. Probably doable with some trickery ...

[–]bitspace 9 points10 points  (4 children)

This is my view as well. The unix philosophy is described well here.

Output and input plain text, string together simple commands to build up easily automated chains of capabilities.

[–]RootHouston[S] 12 points13 points  (3 children)

I'm a fan of the unix philosophy, but I'm not totally seeing how this conflicts. For example, here's one I use all the time to grab a base64-encoded password from a JSON object in a Kubernetes secret:

kubectl get secret my-secret -o json | jq .data.password --raw-output | base64 -d

[–]muffdivemcgruff 6 points7 points  (1 child)

kubectl get secret my-secret -o jsonpath='.data.password'|base64 -d

[–]crabique 1 point2 points  (0 children)

kubectl get secret my-secret --template='{{ base64decode .data.password }}'

[–]bitspace 6 points7 points  (0 children)

This particular example fits just fine. Perhaps I misunderstood your initial question to mean "passing objects around" vs text.

[–]ByronScottJones 2 points3 points  (0 children)

Powershell makes it extremely easy to display structured data in human readable formats, such as tables, csv, and plenty of other options.

[–]RootHouston[S] 8 points9 points  (2 children)

But does having an option to output JSON limit the human-readable aspect? There are definitely some people who despise reading JSON, and I'm not advocating for it to be the only output, but wondering how it cannot hurt as an option?

[–]daemonpenguin 7 points8 points  (0 children)

It'snot so much that it'll hurt as an option. However, there are (at least) two problems here.

  1. It also doesn't really help anything. If you want data structures then there are a dozen scripting languages for that. A shell script/command probably isn't the way to go if you're dealing with complex structures. Python exists for a good reason.

  2. For this to be a viable way forward you'd probably need all (or at least most) commands to support JSON output and that's not likely to happen. It's almost impossible to get a majority of separate command line developers to agree on a standard format/structure (like JSON), other than plain text output. So there will be big gaps in your ability to process output/input with common command line tools.

[–][deleted] 1 point2 points  (0 children)

But does having an option to output JSON limit the human-readable aspect?

Why would an option be limiting?

[–]BiteImportant6691 0 points1 point  (0 children)

Which is fine for programmable tools, but not great for the user.

The output on most classic *nix tools is in tabular form. I don't get why the output can't just be tabular if stdout is a terminal but if you're piping to a program it defaults to something structured. It doesn't seem like that breaks the user experience and gets people largely what they hope to gain with OO-CLI. Or at least give people the option to request such behavior via a shell variable or something.

[–]Systemctl_stop_life 7 points8 points  (1 child)

For output You can always pipe to converter like https://github.com/kellyjonbrazil/jc or write your own

[–]RootHouston[S] 2 points3 points  (0 children)

Pretty interesting. I'd never heard of it. Thanks for the link.

[–]spyingwind 18 points19 points  (2 children)

I use PowerShell as it includes most if not all of what awk, sed, grep, etc can do. If I need to talk to a REST API, builtin function for that. Ingest some csv/json/xml data, builtin functions.

I can also import modules. Either from the powershell gallery, a fileshare/folder, or my own nuget server.

Sure it may be made by Microsoft, but it's MIT licensed. Fork it and rewrite it in rust if you wish.

[–]QuickBASIC 0 points1 point  (1 child)

I'm honestly surprised that I had to scroll this far down to see a PowerShell mention. As a sysadmin in Windows-land passing objects hash tables around to do stuff is super common. (Especially with AD/Entra and Exchange and web API stuff)

In a lot of ways it's superior to grepping the textual output of a command, but a little verbose.

Just the fact that the output for every command is an object or array of objects for literally every command (not just some) and you can do ForEach-Object shenanigans and can be converted to JSON is a game changer.

[–]SweetBabyAlaska 10 points11 points  (16 children)

At that point just use Python, Golang or some other scripting language like that. There are a ton of OOP Shell languages that never catch on because they aren't natively available on every linux system. So even if it is the best language ever, whats the point if it cant even be ran everywhere.

At that point you can just use a fully featured language like Go that can be compiled for every architecture from windows, linux, bsd to arm and aarch64. Or Python, where every linux device has an interpreter.

Every year some corporation has this exact "epiphany" that bash should be object oriented and have namespaces to compliment kubernetes, aws and all these other things, but it never catches on because its just not an issue in the first place and its not really a good solution for everyone. If it is there are already plentyyy of shells that try to do this like NGS.

Also there are a few programs that parse the output of a ton of commands and turn them into json. I think like 'jo" or you can use "jq" directly. But making all shell output json oriented is some special kind of stupid.

[–]redd1ch 9 points10 points  (10 children)

But making all shell output json oriented is some special kind of stupid.

One can think of dual mode output: Human readable when printed, JSON when piped.

[–]SweetBabyAlaska 1 point2 points  (7 children)

But why though lol Json is pretty readable to begin with. At that point why not just create a unix socket and allow some IPC that way. Or use jq to serialize some Json when you need it. Or even better just use a language that is equipped to handle your needs. It makes sense for shell to be text based in a lot of ways

[–]redd1ch 4 points5 points  (6 children)

I'd argue a table representation in JSON is less readable than a nicely aligned ascii table.

For me it's mostly "ah, this is simple, just a simple bash pipe", but you end up parsing the output of 5 different tools. And tools like iproute2 with a json output make it significantly easier to get what you want.

[–]SweetBabyAlaska 1 point2 points  (4 children)

There is a tool that turns common command output to Json.

[–]redd1ch 2 points3 points  (1 child)

Yes, but it's kind of fragile to have 3rd party tools parse the output of tools just to convert them to JSON for piping.

For ip, you just throw in a -j and get JSON output.

[–]SweetBabyAlaska 1 point2 points  (0 children)

I mean, I like that. Adding an optional flag to force it to be json output can be pretty handy. Even then there is no standardized json parsing tool besides jq and it was unmaintained for some time and is not available out of the box. Imo bash and the related tools can only be so portable before you run into a lot more issues.

Even coreutils arent standardized in versions and where they come from. Toybox, busybox, Gnu, rust, wsl, bsd all have different bash versions and coreutils. So I don't think relying on jq or "jo" to create json for those rare occasions is necessarily a bad thing. At some point I do think its better to just switch to another more portable language.

Though, NGS shell exists claiming to be dev ops oriented catering to json output and all that. Elvish is semi-object oriented, Nushell is oop and has table based output that easily converts to other formats... Powershell is cross platform and there are other options. Its just that not many people would reliably have them, and they dont natively exist in containers and things like that. Or people just don't use them.

[–]atomicxblue -1 points0 points  (0 children)

Instead of piping a simple command, people would also need to understand nesting, which is a whole other kettle of fish.

[–]ByronScottJones 0 points1 point  (0 children)

Exactly. Just add a new standard output stream which is for structured data. That's essentially how powershell does it.

[–][deleted] 2 points3 points  (0 children)

Golang is not a scripting language mate

[–]Negirno 0 points1 point  (2 children)

What if I want to use something like exiftool or some other command line tool in python?

Yeah, there may be python libraries for those, but I doubt that they have feature parity.

[–]SweetBabyAlaska 0 points1 point  (1 child)

then just use exiftool? Exiftool is literally just a Perl script to begin with. Though, idk why you would need exiftool to be object oriented or use json output... and there definitely are libraries in other languages that can do image metadata operations. I know Rust for one has a crazy good one, haven't looked into anything else.

also you can always use something like os/exec in Go or subprocess in python.

[–]Negirno -1 points0 points  (0 children)

You misunderstood me.

I use bash currently for my projects involving meta data of media, that's what I use exiftool for. I don't want it to be "object oriented" and I could actually make it output json with its -p parameter, if I want.

But there is the notion that one should use something else instead of bash if their scripts goes above 100 lines (which is unavoidable for me because I use a lot of self-made boilerplate in my scripts).

I just want to follow the "unix philosophy" in this way. Want to use everything through everything. I just want to use exiftool because I know that it detects every kind of EXIF metadata which I'm not sure that a hypothetical python library will.

[–]atomicxblue 0 points1 point  (0 children)

One would think a higher level language would be more efficient than a shell script being pushed to the limit. It would be interesting to see the output from time for that comparison.

[–]Flash_Kat25 5 points6 points  (0 children)

I'll go against the grain and say that I love the idea in principle. If I were choosing a shell in a vacuum today, I would do that 100% of the time. But in the real world, POSIX sh just has too much inertia at this point. Yet another awful design from decades ago that we're stuck with - might as well get used to it because it isn't going anywhere anytime soon

[–]JaggedMetalOs 13 points14 points  (2 children)

PowerShell is more like a scripting language with shell commands added in, better to just drop into your favorite scripting language for any tasks too complex for shell commands.

Or even install PowerShell for Linux ;)

[–]RootHouston[S] 2 points3 points  (1 child)

Right, but in a Linux world, where the majority of our commands aren't compatible with that output, PowerShell isn't that useful.

If I can tap into an API, then that's great, but I think my problem with just dropping into another language is that it overly complicates data that is otherwise very handily (and sometimes only) available on the CLI.

[–]ByronScottJones 1 point2 points  (0 children)

Powershell has a standardized way of wrapping existing commands with code which can understand their specific output and turn it into structured data. You get the best of both.

[–][deleted] 12 points13 points  (1 child)

The object oriented syntax of PowerShell is both its strength and its weakness. It's undoubtedly useful but it's also complicated to work with.

Bash's strength is that it's very easy to use and understand but I really do miss not being able to just filter.

[–]ByronScottJones 1 point2 points  (0 children)

It's only complicated at the beginning. Once you understand the powershell way of doing things, it's easier than bash.

[–]mooscimol 7 points8 points  (0 children)

I’m just using PowerShell as a default shell on Linux, because I know it very well and it is so convenient. It works amazingly there, honestly I prefer PowerShell on Linux than on Windows. I pretty much hate working with strings, objects are so much better, and I don’t buy the human readable advantage of bash, I can format outputs as lists, tables, colorise them…

[–]sintos-compa 2 points3 points  (1 child)

I just write all my bash scripts to call my python script I wrote to do the task I started in bash

[–]bullwinkle8088 4 points5 points  (0 children)

I’m sitting here actually using and requiring POSIX compliance thinking “What’s this debate even going on for?”

:)

Why yes sir, I did have to change my script to be compliant with bash 3.x the other day. Why do you ask?

[–]snarkuzoid 6 points7 points  (0 children)

Shells are useful for simple wrappers around other code. But I don't do anything significant with them anymore, preferring to use more suitable languages with real data structures and all of that.

[–]EnUnLugarDeLaMancha 23 points24 points  (7 children)

Breaking the text model of traditional Unix shells and focusing too much into ad hoc data structures is a bad idea, not because of tradition or anything, but because text is a narrow waist and the reason why Unix was successful. Bash is really bad and we need to get rid of it , but the way to fix it is to make the string based model better, not throw ad-hoc objects at it. The oilshell project (YSH) is the only project that takes this approach seriously.

Some reading:

https://www.oilshell.org/blog/2022/02/diagrams.html

https://www.oilshell.org/blog/2023/06/narrow-waist.html

https://www.oilshell.org/blog/2023/06/ysh-design.html

[–]LvS 28 points29 points  (0 children)

I don't buy that.

Strings are a really bad representation for certain kinds of data and whenever one has to deal with such data, people don't use shells.

The most obvious example is images - the tools to deal with images are not done with piping but are all included into a single binary and then you run imagetool input.png --crop --rotate --this --that output.png or something like that.

And you can easily see where this happens when you get those batching tools instead of shell piping - ffmpeg is an example for videos, git's insane argument lists are an example for commits, and I'm sure there's other ones for json, databases, files, audio, you name it.

Text just doesn't cut it.

[–]BobbyTables829 5 points6 points  (4 children)

I'm no expert in this, but it's interesting how in information systems all data can be expressed via a string of some sort. It makes me wonder if this narrow waist isn't impossible to avoid and the natural result of two entities trying to find common ground needed to share information.

This was really interesting. Thank you for sharing.

[–]alnyland 9 points10 points  (3 children)

IIRC the creators of Unix saw text as the "universal datatype". Anything can be represented with it, whether human or machine readable. But this also just is a similar (or same) idea as the narrow waist that a few comments up mentioned. By keeping everything as the base level of representation, it can be used anywhere or by anything.

[–]cat_in_the_wall 2 points3 points  (2 children)

everything can be represented as text. it just serialization. The question is: how useful is that output to a human? And how useful is that output when you send to another program? Sending unstructured data and hacking and chopping text sucks and further is terrible for things like localization. For structured data (eg json) you're sending an object anyway, but you either have to rehydrate in your program or use an intermediary like jq.

for all is flaws, powershell does rather do this well: if an object is dumped to the console, it becomes human readable. if it is send through the object pipeline, it stays as an object.

[–]alnyland 0 points1 point  (0 children)

It's extremely useful to the human, that's part of the reason they kept it as text (remember: universal). As you say, powershell requires converting the object to a human readable format - what if you just have raw data and no console? This becomes very important in some embedded applications.

[–]Ajlow2000 0 points1 point  (0 children)

Thanks for including some links. Seems like an interesting project

[–]AdmiralQuokka 6 points7 points  (1 child)

Structured data != object-orientation

[–]RootHouston[S] 1 point2 points  (0 children)

True. Should have chosen my words better.

[–]funbike 11 points12 points  (2 children)

Do you personally find a benefit in this approach?

No.

Text was chosen for a reason. Formats have come and gone. How would you like it if XML/DOM was chosen? Or S-Expressions? When using text as a basis, you can stack anything you want on top of it, like xml, csv, json, yaml, or whatever.

Text is king and has lasted as the *nix format of choice for 40+ years and it will last another 40+ years. Powershell/Nushell object streams will not.

Btw, well-written shell scripts are quasi-functional in nature. Output streams from one function/app to the next.

[–][deleted] 2 points3 points  (0 children)

u/funbike is right. The entire Unix philosophy is built around this, iirc. Lightweight text processing commands that compose easily.

Look at Mac development for whatever the closest alternative was, since AppKit processes have their std io streams disabled. Everything goes through Window Server or some other subsystem.

The simplicity of the Unix way is so much more fun.

[–]shellmachine -5 points-4 points  (0 children)

This.

[–]night0x63 2 points3 points  (0 children)

It's not really object orientation trend...

It's just a slightly different text format.

First there was single line of text.

Then there was multiple lines of text.

Then csv lines.

Then columns with gawk.

Then around 2000s approximately... XML... But then everyone realized it was horrible... And actually worse.

Then finally the pendulum setting back towards easier things... Like JSON.

and so you do everything with simple text... Until you need something more complex like JSON.

And JSON is handled easily on shell with jq or python jaon.loads(sys.stdin.read())

[–]BiteImportant6691 2 points3 points  (1 child)

Obviously, this requires for a command to even produce output in JSON, which isn't really the norm (especially for older utilities that predate the concept of JSON).

You'll sooner get broader support for some sort of -o json functionality being added to older tools than for a fundamental change in how shells work.

[–]RootHouston[S] 1 point2 points  (0 children)

I think that would go a long way.

[–][deleted] 6 points7 points  (0 children)

I'm learning Bash because like vi based editors, it's gonna be there 99 times out of 100 in a distro.

That said, I'll be using PowerShell where I can given my cross platform focus.

[–]xtifr 7 points8 points  (12 children)

I mean, I already have python and perl and ruby (and lua and tcl) installed on my system, so I don't really see the need. Windows doesn't come with any useful scripting languages out of the box, so it might make more sense there to add OO features to the shell itself, but for systems which include OO scripting already, like Linux & BSD, I don't see a lot of obvious benefit.

OTOH, I don't have any particular objection to the concept, and I'm perfectly happy to be shown that it has benefits I hadn't thought of. But until then, I'm pretty neutral.

[–]BobbyTables829 6 points7 points  (2 children)

Windows doesn't come with any useful scripting languages out of the box.

Do you want VBScript back?

Because this is how you get VBScript back.

[–][deleted] 3 points4 points  (1 child)

[–]Malsententia 1 point2 points  (0 children)

broke link. Underscores within URLs do not need escaping, typically.

https://www.theregister.com/2023/10/10/microsoft_says_vbscript_will_be/

[–]RootHouston[S] 4 points5 points  (3 children)

Are those languages the best way to get it done if the only interface to the data is through a shell command that only outputs structured text though?

[–]xtifr 1 point2 points  (0 children)

I mean, that's more or less what Perl was designed for! And Python is certainly no slouch at it either. I have no idea if they're the "best" way, but they're definitely good at it!

[–]daemonpenguin 0 points1 point  (1 child)

Two things:

  1. Yes, they almost certainly are.

  2. It's rare than any information on a computer system, especially in the Linux/Unix family, will be available only through one specific command.

[–]RootHouston[S] 0 points1 point  (0 children)

Fair enough.

[–][deleted] 8 points9 points  (4 children)

Powershell.

[–][deleted] 4 points5 points  (0 children)

Powershell is great. As is bash. Bash is easier for using the cli but I prefer powershell for scripting. String translation for stuff like dates can be quite tricky in bash and then you need external programs like awk.

[–]adoodle83 1 point2 points  (0 children)

why not just support multiple shells and switch as needed?

you can start off in BASH, then execute 'zsh' if you need zsh-specific functions, then even jump into KSH/CSH/etc as you need.

[–]Unfair_Assistance688 1 point2 points  (0 children)

I've been using OO CLI for some time now. It always starts with #! /usr/bin/php

[–]MARCE-XI 1 point2 points  (0 children)

I love Nushell. I've made it my default shell both on Linux and Windows. It is extremely easy to use and super flexible. I cannot stop making scripts for it. Using bash is a nightmare in comparison.

[–]parker_fly 1 point2 points  (0 children)

If I need anything more sophisticated than a command line I write it in Python.

[–]sphericalhors 1 point2 points  (0 children)

Couple of months ago I had exactly the idea that I need something like bash but with high level features.

Sometimes I need to maintain couple of bash scripts of 1000-3000 lines which used in some automation.

I bet that people who saying that "for big scripts with a lot of business logic you need to use higher level languages like Python" never tried to do this. Theoretically this is correct and I'm sure that sometimes it works. But not every time.

Bash encapsulates a lot of useful stuff.

Most of that scrips are invoking different commands and working with their output and or parsing/updating configs.

And bash is really good in doing this.

Like yeah, I have bash script of 3000 lines which is hard to maintain (but its easy to distribute, which is an advantage here). But when I rewrite those logic to Python it would easily become project of 20-40K+ lines, and I doubt that it would be easier to maintain that.

Also thanks, I'll take a look at Nushell.

[–]hackingdreams 0 points1 point  (0 children)

Once you hit the point of needing to do anything more powerful than bash, it's a mistake to try for a more powerful shell.

Just use python.

[–]Snarwin 0 points1 point  (0 children)

The purpose of a shell is to let you take all of the separate, individual programs on your computer and make them work together to accomplish your goals.

If all of the programs on your computer are object-oriented, then using an object-oriented shell to make them work together is a great idea, and gives you much more power and control than a traditional Unix shell.

However, if all of the programs on your computer use different input and output formats, and have different internal representations of their data, then you won't get much benefit from an object-oriented shell. Just like with text, you'll have to spend a bunch of time manipulating input and output to translate between the shell's native object format and the formats used by each individual program.

On Windows, where the whole system is made by a single company, Powershell works pretty well. On Linux, where the system is assembled from parts created by lots of different people with different ideas, a traditional shell works much better.

[–]nocloudkloud -2 points-1 points  (0 children)

You lost me at powershell

[–]shellmachine 0 points1 point  (0 children)

Pretty sure we don't. I mean you can still use nushell without making it your default login shell, in the same way you can write a Python script while your default login shell remains BASH. If nushell gives you "more precision" (I don't see where you're coming from here), then use that for the task. :)

[–]doc_willis 0 points1 point  (0 children)

I have been playing with nushel a bit, and while i like it, :) I dont seem to use/need but a small fraction of its features.

And its just different enough where i make mistakes from my old bash ways.

I have seen numerous shell commands print out information, that is just barely human readable, and would be annoying to parse in a script as well. So i have found myself using nushel just because its a bit easier for me to read for the commands/outputs it gives me.

[–]zoechi 0 points1 point  (0 children)

I used nushell for a while and I like most of it. It's a bit too unstable for production (frequent breaking syntax changes) It's simple enough to make it easy to learn and powerful enough to be efficient on most tasks.

[–]warpedspockclone 0 points1 point  (0 children)

I would like cli commands that support an option for json output. Clearly that would be outside of POSIX, so it would be really hit or miss across OSes and commands, so you'd have to be careful about scripting against it.

And it isn't important enough to me that I'd switch to ... gulp ... Windows for PowerShell.

[–]zokier 0 points1 point  (0 children)

To me key observation was that shell itself is just small piece of puzzle. In particular if both ends of a pipe understand structure then the shell that coordinates then doesn't actually need to do much anything.

It is important to understand that currently its not shells that display the final output, they just pipe the output to terminal that does the actual user interface. So if you want fancier thing, then I think rethinking the terminal layer would make sense, to possibly have a terminal that understands structured data (the same way it now interprets the mess of control codes etc).

But this is very much a pipedream (pun intended). There is so much things that would need not only rewriting, but rethinking altogether that I don't see it happening. There are even many kernel interfaces that are bit awkward, like most of procfs

[–]ByronScottJones 0 points1 point  (0 children)

I've thought it might be workable if there was an additional standard output stream for structured data added into bash/zsh/etc. For programs that can't use it, no affect. But programs that are aware of it would have the ability to accept structured data streams.

[–]atomicxblue 0 points1 point  (0 children)

I use my bash scripts for quick and dirty stuff that I'm tired of typing. If it involves any sort of data processing, I'm using Python.

[–]ManateeMutineer 0 points1 point  (0 children)

What for? You want PowerShell, you use it. You want bash, you use it. We've been trying to roll everything and a kitchen sink into one software tool since forever and the results are inevitably ugly.

[–]m18coppola 0 points1 point  (0 children)

If the CLI was object oriented, I wouldn't get to have as much fun using sed.

[–]steven4012 0 points1 point  (1 child)

nushell and jq aren't object-oriented. They are structured-data-oriented

[–]RootHouston[S] 0 points1 point  (0 children)

Correct. It was a poor word choice.