Live data from Hacker News

Nushell: Introduction to a new kind of shell

dataswamp.org

241–250 of 252 posts

Re: Nushell: Introduction to a new kind of shell

#241

Earlier quoted context omitted.

The only thing to keep in mind about Zsh parameter expansion is that unquoted empty values will be dropped entirely, while quoted empty values will be treated like the empty string '': show_nargs() { print $# } q= show_nargs $q # 0 show_nargs "$q" # 1 So it doesn't completely solve the need for defensive quoting, but at least it mitigates the need for the most part.

Ouch, that is a sharp corner: $ echo 'aaa' > a.txt $ echo 'bbb' > b.txt $ TMP_DIR="" # Mistake! Missing arg, failed search, typo'd name, etc. $ cp a.txt b.txt $TMP_DIR $ cat b.txt aaa $ # The contents of b.txt are lost.

cp itself should have been two commands, or at least accept two flags for those two very different semantics.

Actually there's a wave of unixy tools being written in Go and Rust and I think there might be a suitable cp replacement already, but it's up to distros to package it.

Re: Nushell: Introduction to a new kind of shell

#242

Earlier quoted context omitted.

When you work on multiple OSes (mainly macOS and Linux), having your dot files normalized is IMHO the best experience, yes, I have symlinked, but if I need to setup a new mac (that does not happen often) then I could forgot about it and will take an extra step to setup, as I said that's just my preference. Also I want to say that the ~/Library/Application Support directory only works good for desktop app, so it's eas…

iterm2 puts config in ~/.config, while also having a directory in ~/Library/Application\ Support/ (habit). The author of iTerm has more credibility than the person you're replying to imho. If a program is putting text files a user is supposed to edit in that directory, that's a mistake. If the application doesn't live in ~/Applications and provide a GUI for editing configuration, the file belongs in ~/.config and the…

The XDG standard is a Linux standard, for compatibility between Linux distributions. Writing to ${XDG_CONFIG_HOME:-~/.config} on a non-Linux platform is like writing to ${APPDATA:-~/AppData/Roaming} on a non-Windows platform. I will never understand where the habit of assuming Linux standards are universal standards comes from.

There is nothing in Apple's documentation about Application Support being incorrect for CLI applications. It is an ex post facto justification for apps that do the wrong thing on Linux too and don't want to go to the effort. They are almost guaranteed to do the same thing on Windows and not even go to the effort of setting the folder as hidden.

Re: Nushell: Introduction to a new kind of shell

#243

Earlier quoted context omitted.

I am a C# programmer at heart, and I use powershell a good bit. I can honestly say I can never use powershell without my cheat sheets or my list of favorite commands (and especially the arguments to use). I looked at this and kinda get it and think I could do some things with it. I don't think it's as powerful and can _definitely_ say it won't be capable of the same automations we use. That said, the text parsing peo…

> can _definitely_ say it won't be capable of the same automations we use. Anything in particular you think would be difficult/impossible in Nushell? (I'm one of the Nushell developers, might be able to help or put features on the roadmap)

Honesty, I believe this because of the maturity of powershell and not any inability in nushell. Having literally the number of commandlets and having entire .net framework available makes powershell have more options.

Additionally, pretty much every Windows Server feature is commandable with powershell. Some (much?)_ of the UI stuff in windows is just using powershell under the hood.

That said. I am _very much_ looking forward to using nushell when I use linux or wsl. And I wish your team great success. Linux needs it.

Re: Nushell: Introduction to a new kind of shell

#244

Earlier quoted context omitted.

> can _definitely_ say it won't be capable of the same automations we use. Anything in particular you think would be difficult/impossible in Nushell? (I'm one of the Nushell developers, might be able to help or put features on the roadmap)

Honesty, I believe this because of the maturity of powershell and not any inability in nushell. Having literally the number of commandlets and having entire .net framework available makes powershell have more options. Additionally, pretty much every Windows Server feature is commandable with powershell. Some (much?)_ of the UI stuff in windows is just using powershell under the hood. That said. I am _very much_ looki…

Yeah, we're probably never going to be able to compete with PowerShell's sheer volume of Windows integration points. Shelling out to pwsh is probably the best we can do in some situations.

Re: Nushell: Introduction to a new kind of shell

#245

Having written a lot of shell scripts, the single greatest thing I've ever experienced is shell-friendly outputs. For example, consider if ls had a "--shell" option that output each entry as a single line of shell-quoted variables safe for eval: # cd /usr/share/dict # ls --shell words path="/usr/share/dict" file="words" user="root" group="root" size=985084 ... Then all sorts of things become easy. # eval $(ls --shell…

Part of it is knowing the tools. In this case, 'stat' is the command you probably want to get parsable details about a file, not more options to 'ls'. I often see convoluted shell scripts that could be a lot simpler with the use of more appropriate utilities.

It's just an example. With shell-friendly outputs you can recreate "ls -l" with any field order you want with just a few lines of readable shell script. Many of the unix tools only exist because it's so hard to parse the human-readable output in the shells.

Re: Nushell: Introduction to a new kind of shell

#246

Earlier quoted context omitted.

In the past, I've toured these alternate, non-POSIX shells like Nushell. A lot of them (e.g. Powershell, Elvish) don't provide job control. I looked into how job control works and it's kind of a bother, so I see why they might have elided it. I wonder if multiplexing the terminal using tmux or screen is a good enough alternative the job control for many use-cases. You do lose state (i.e. environment variables, workin…

My data point: I prefer tmux/multiplexing over job control because the process hierarchy leads me to managing them better (I never accidentally quit tmux). Also I don't have to worry about std stream usage. I'm actually not sure of a case I'd care for job control.

The problem with tmux is that I often start a long process without really realizing it, then control-Z bg to continue working with the shell. With tmux, I'd need to either realize up front I'm about to start a long-living thing, or lose the context of the current shell to continue my interactive work.

Re: Nushell: Introduction to a new kind of shell

#247
post #238

Earlier quoted context omitted.

In the past, I've toured these alternate, non-POSIX shells like Nushell. A lot of them (e.g. Powershell, Elvish) don't provide job control. I looked into how job control works and it's kind of a bother, so I see why they might have elided it. I wonder if multiplexing the terminal using tmux or screen is a good enough alternative the job control for many use-cases. You do lose state (i.e. environment variables, workin…

Sorry, but you're incorrect here. PowerShell does most definitely provide job control. Get-Help about_Jobs Alternatively, online documentation from Microsoft regarding jobs: https://learn.microsoft.com/en-us/powershell/module/microsof...

I think you must be unfamiliar with job control, but I could be wrong. How do you Ctrl+Z a foreground job, maybe several, and then switch between them.

All of what “powershell” provides depends on knowing you want to background something ahead of time, and even then I don’t think you can make it the foreground task (maybe wait job comes close) There is even a Github issue on it, which I’m afraid I can’t be bothered to go find again

Re: Nushell: Introduction to a new kind of shell

#248
post #15

How did I not know about this? I will never parse text in Bash again.

But... Bash (sh) is not meant to parse text! Bash (sh) is glue. awk can parse text. As can SNOBOL4 if you REALLY want to go crazy. Or sed. Math is done by expr, dc and bc.

'In a way, Nu is a way of saying “what if we didn’t need tools like awk so often?” Since you’re working with structured data, as we add more support for file types, it’s less often you need to reach for “awk”, “jq”, “grep”, and the array of other tools to open and work with common file types.'

From this interview: https://www.notamonadtutorial.com/nushell-the-shell-where-tr...

Re: Nushell: Introduction to a new kind of shell

#249

Earlier quoted context omitted.

> anti-semantic Why? > non-portable PowerShell 6 and later run on Windows, macOS, and Linux. > verbose This is by design.

> > anti-semantic > Why? I can't speak to the other poster, but I found the PowerShell example to misleading because it required the presence of a variable that the Nushell did not. I had to read through the code three times to understand: - Whether the code was modifying some fundamental environment variable that would affect the running of other programs? - If the variable would need to be accessed after the comman…

> can't speak to the other poster, but I found the PowerShell example to misleading because it required the presence of a variable that the Nushell did not.

This was just a choice of OP and also isn’t a concern in PowerShell:

  gc ./some.yml | ConvertFrom-Yaml | ConvertTo-Json > some.json

Re: Nushell: Introduction to a new kind of shell

#250

Earlier quoted context omitted.

haha, thanks for this. i was looking at the examples on the other page and was like, "jfc, no thanks"

It's someone's personal blog post. No need to be mean. The styles are a little brutalist but also readable to me.

i wasnt talking about the css…

i mistook the blog for the an official introduction and was turned off by the complexity of the examples. which i stand by—that’s a poor introduction to the shell.

Post reply on HN