Hacker News new | ask | show | jobs
by Aerbil313 858 days ago
Seconded. I am very young, never bothered to learn bash, went straight for fish. ChatGPT is there to help if I ever encounter unintelligible “$@“&2>?!¿…

Gonna try nushell soon as that seems even more productive.

2 comments

Nushell is great fun, but be prepared to encounter and fix errors when you paste code designed for sh/bash/zsh/fish. It's a much bigger step away from convention than the others.

I think the one that catches me off guard the most is:

    export FOO=bar
    BAZ=qux
Is now

    $env.FOO = "bar"
    BAZ = "qux"
It makes more sense the nu way, but old habits die hard.
I don't see much use for such pasting and fixing up— I generally find it more painful than other methods.

For short snippets, better to read, understand, and translate as you type.

For some shell integrations or environment setup tools, use fenv or babelfish.

For scripts of any length, just save it and run it. The shebang'll invoke bash or whatever is needed.

nushell requires double quotes around values? looks like powershell where everything-is-an-object of something-else
If you want those values to be strings, yes. For instance, it knows that this is a list of ints:

    $ [1, 2] | math max
      2
And here are some strings:

    $ ["a", "c"] | str join "b"
    abc
And there are tables

    $ [
       {name: "foo", value: 6},
       {name: "bar", value: 9}
      ] | where value > 7 | get name
    bar
And that's about as weird as the types get.
I also never bothered to learn Bash... `#!/bin/sh` all the way!
as such doing that yields different results based on am i on a mac, in debian, in a container, am i on a zebra-on-the-moon...

its all a bunch of loops and string manipulation in the end. in fact, awk can handle a whole lot of it too! and octave... and others, lol; so long as it does not turn into the python2 to python3 fun we've had in the past and we have some stability between versions; this is why i still choose bash (and the whole gnu binaries)

edit (formatting i hope, and python)

I'll admit that I haven't tried this on other platforms, but I was under the impression that the opposite should happen: `/bin/sh` loads a basic POSIX-compliant shell that should work on other platforms, with Bash, Zsh, and whatever else, which are extensions of a POSIX-compliant shell.

Blegh, now I have to do some digging...

sh will load whatever the OS decides it to open LOL; there is no rule. again why i just go with gnu bash as it is pretty feature rich and exec's other-cli-apps really well. the loops it can do, and arrays are just a bonus; if i need some more complex data structure, then there's another app for the job- that is not an interactive shell. just beware of the dragons when dealing with macos's old-ass bash; check out the version, go with new if you can