Live data from Hacker News

Nushell: Introduction to a new kind of shell

dataswamp.org

141–150 of 252 posts

Re: Nushell: Introduction to a new kind of shell

#141
post #96

Earlier quoted context omitted.

`dirs -v` would be `Get-Location -Stack`. Also in newish versions PowerShell `Set-Location` (aliased to `cd`) supports -/+ to move backwards/forwards in it's own history, so usually you don't even need to bother with `pushd`/`popd` unless you need a named stack.

what about pushd 7 to go to the 7th path in the stack?

Just get the 7th path from `Get-Location` and `Set-Location` there, e.g.

  function Set-StackLocation ($Position) {
    (gl -Stack).Path | select -Index $Position | cd
  }

Re: Nushell: Introduction to a new kind of shell

#142

I just ported a bunch of scripts to nushell. I hit some bugs, a couple of which are a bit sharp, but wow, the list of quirks I have to remember for nutshell are so much fewer than for bash. Constantly impressed at the errors it catches at parse time, kinda crazy sometimes. Oh my god I could cry, strings are sane to work with. I may never write a bash script again (it's okay, I use Nix so I get nushell everywhere I'm…

> I may never write a bash script again I wrote 2x 200 line-ish shell scripts recently, and it was simply terrible, and although I'm increasingly convinced we need a shell like abstraction, I can't believe `bash` is the best we can do. Really hope I find one of these alt shells that suits me. Not a fan of Python but xonsh looks really cool too.

Bash is not the best we can do!

If you want a traditional Unix-like shell that is mostly sensible in the places where Bash is not, check out Zsh. It has a ton of complicated features, but most Bash scripts can be ported easily (if not outright copied and pasted). Zsh has fewer footguns by default than Bash, and it has more "safety" settings that you can enable.

There is also the Oil shell, whose creator often posts on HN, and which I think is meant to be a superset of Bash, but I have not used it myself and can't vouch for it.

As for the alt shells, I've was specifically interested in Elvish, but I dropped it as soon as I saw that they don't support parameter interpolation in string literals, like `"${HOME}/.local"`. This is such a common operation in shell scripts that I have no interest in a shell that doesn't support it, and I can't imagine why Elvish doesn't.

Re: Nushell: Introduction to a new kind of shell

#143
post #90

I just ported a bunch of scripts to nushell. I hit some bugs, a couple of which are a bit sharp, but wow, the list of quirks I have to remember for nutshell are so much fewer than for bash. Constantly impressed at the errors it catches at parse time, kinda crazy sometimes. Oh my god I could cry, strings are sane to work with. I may never write a bash script again (it's okay, I use Nix so I get nushell everywhere I'm…

Honestly I’ve enjoyed working with PowerShell for scripts to work for all developers on my team regardless of what OS they are using.

I wanted to like Powershell, but it is missing some features that I think are essential. For example, apparently checking the return status of an arbitrary command is not trivial, and there's no equivalent of `-eu -o pipefail`. Yes, I know `-eu -o pipefail` is imperfect too, but it covers most common cases. I also struggled badly to stop it from mangling the output encoding of my applications (no, I don't want a goddamn BOM, thank you), and the solutions I found all either had no effect or required me to write what looked like C# code embedded in my shell script.

Re: Nushell: Introduction to a new kind of shell

#144

I use it as my primary driver, for the sole reason is that it's the only cross-platform shell that properly supports Windows (without resorting to Cygwin/MSYS, which has performance issues and many pain points). I'm still getting used to the syntax though... (Edit: forgot to mention Powershell, since nowadays it also works on Macs and Linux)

Why use this over PowerShell for example?

It's dumb but I personally can't get over Camel-Kebab-Case commands. I hate typing Caps, and hyphens.

Re: Nushell: Introduction to a new kind of shell

#146
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 words); echo "$size" "$file"
This nushell doesn't really change anything important about this biggest scripting problem. You're still parsing human readable output and it's still dependent on particular versions and options passed.

If I had a genie wish of nushell being installed everywhere or even just coreutils having a --shell option I'd take the latter any day.

Re: Nushell: Introduction to a new kind of shell

#147

I just ported a bunch of scripts to nushell. I hit some bugs, a couple of which are a bit sharp, but wow, the list of quirks I have to remember for nutshell are so much fewer than for bash. Constantly impressed at the errors it catches at parse time, kinda crazy sometimes. Oh my god I could cry, strings are sane to work with. I may never write a bash script again (it's okay, I use Nix so I get nushell everywhere I'm…

I learned PowerShell some time ago. I really like the concept and the power that comes with it. But, coming from Bash, I can't get a grip of the syntax.

I am in the process of switching most of my shell scripts over to Python; I wonder whether nushell would be the better option.

Re: Nushell: Introduction to a new kind of shell

#148

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…

I like the idea, but if it was interpreted directly, that would be a security nightmare unless we also had something like Python's ast.literal_eval(). Which makes us come back to JSON-like outputs because we need some form of serialization anyway, I guess.

Re: Nushell: Introduction to a new kind of shell

#149

>This is just an example from YAML to JSON, but you can convert much more formats into other formats. >open dev/home-impermanence/tests/impermanence.yml | to json I can do it with PowerShell: $os_list = (Get-Content -Path "C:\temp\operating-systems.yml" | ConvertFrom-Yaml) Set-Content -Path "C:\temp\PowerShell_operating-systems.json" -Value ($os_list | ConvertTo-Json)

I mean, yeah? As much as I hate to admit it (and believe me, I hate to admit it), PowerShell is better than bash at composing tools made by all sorts of people on the fly in easy to write pipelines. I have my issues with it as a language, but it's not like I'm thrilled to write bash. Nushell is an attempt at making a scripting language which builds on bash, rather than supplanting it. PowerShell is much less nice on…

Yeah, PowerShell eliminated the output parsing overhead which was the significant portion of any composed shell operation. That's where all shells need to be heading I believe.

Re: Nushell: Introduction to a new kind of shell

#150
post #141

Earlier quoted context omitted.

what about pushd 7 to go to the 7th path in the stack?

Just get the 7th path from `Get-Location` and `Set-Location` there, e.g. function Set-StackLocation ($Position) { (gl -Stack).Path | select -Index $Position | cd }

Seems like a lot of work for something that's just built into bash and is extremely useful.
Post reply on HN