Hacker News new | ask | show | jobs
by overbytecode 854 days ago
The age-old question, do I strive to learn new tools that are better designed (Xonsh, Nushell, Fish)? Or old tools that are omnipresent (Bash/Posix)?

I like Xonsh, it’s pretty nice to work with, but it makes going back to Bash, when I have to, even more painful.

12 comments

Better to live in paradise most of your life even if you have to go back to bash hell once in a while rather than endure that pain all the time
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.

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
Nah, hell is everywhere. I'm better off using Bash when I need a basic script, then upgrading to Python if I need anything more substantial.
Take a look at https://github.com/xonsh/xonsh/issues before deciding to abandon the devil you know.

I prefer sticking with bash where necessary (where a script is the only thing that will reasonably work), and elsewhere using a programming language with testing, type checking, modularity, and compilation into something with zero or minimal runtime dependencies.

I use zsh on my work and personal computers. I'm not ssh'ing into boxen these days. But when I do, I'm not doing anything more than reading logs to figure out why the userdata on an EC2 didn't work as expected.

I try to use posix standards when convenient, but I'll switch to bash at the first sign of posix complexity.

Xonsh seems like I'd have to type a lot more than I do with zsh. I would also be concerned about not being able to give my team members the same command I used without forcing them into a non-standard shell.

I don't use fish because I've only met one other person IRL who used it. Everyone I've worked with has use bash, zsh, or ksh (I'm glad I left the ksh company before they had to rewrite all those ksh scripts).

Also, Bash is staying for now. posix will most likely always work for the foreseeable future. Zsh seems to be the new Bash, but I have yet to see anyone put zsh in a shebang at work.

> I have yet to see anyone put zsh in a shebang at work.

I put it in shebangs for macOS scripts nowadays, since it's been the default shell on macOS for a little while. That's a niche for sure, but still.

I found xonsh to be configurable to be extremely similar to zsh. I don’t see that it’s «more typing».
I recently (i.e., yesterday) migrated my 15+ year old bash config to zsh. zsh has some great quality of life improvements compared to bash and is basically 1-1 compatible. I had to spend about an hour migrating my prompt, but other than that it was a smooth transition.

zsh is now the default shell in macOS, so I'd say it's a safe bet if that's what you work with.

I switched a few years ago and while there's a lot to like about (and power in) zsh, there's a lot i really dislike about it. For starters, it adds so much additional functionality and compatibility that the documentation (man pages are terrible). Also, the additional history & variable expansion capabilities are messy/ugly in shell syntax (imho). I think ultimately the problem is that, for shell scripting, bash has clearly won, but other shells show that there's room for an alternative specifically for a user's interactive interface...but zsh didn't get the memo so is trying to be all things to all people. One of these days, i'll probably swing over to fish...if I can get the energy to change my environment yet again.
"basically 1-1 compatible"

careful, there are footguns in those words. It may seem like it's 1-1, but it's not. There are subtle differences especially in escapes. Bash uses \ escapes. Zsh uses % escapes. Zsh has builtin wildcard expansion. There are other differences as well but you can use the emulate command to emulate bash so it actually is 1-1.

Also, once you've made the switch to zsh - checkout oh-my-zsh (https://ohmyz.sh/)

it's pretty funny that Zsh only came out one year after Bash... in 1990
Learn the new tools. I’m working on my own machine 99% of the time, and if I’m on a remote machine, there’s a 90% chance I’m running something automated there. I’m not going to handcuff myself to the baseline for the sake of that .1%.

There’s no way I’d go back from Fish to Zsh or Bash on my daily driver. It’s just too pleasant to give up just because of “what if?”.

If it's Python, is it really a new tool?

The big problem is that bash is more or less portable (almost everything has bash in the box). They need to start convincing distros to include and/or default xonsh, to really make it worthwhile.

In my view, yes. It would allow you to extend you shell easily, for example do something with the history, like setting a blacklist for commands that should not appear in the history when using the up key, but still retaining the execution of such a command in the history for poor man's auditing.
If you're new and still trying to get into the industry, try all the new tools. Drive them hard and try to break them, so that you can find bug fixes you can contribute. Just go nuts, and let yourself steadily build up a backlog of unique, public, referencable commits you can show employers.

Once you're already established and comfortable, it's up to you if you want to keep trying the new flavor of the week. People gravitate towards novelty at different parts of the stack: Some people love running FreeBSD or Alpine, but stick to Bash on top of those; others, like me, try to stick with Ubuntu whenever possible, and mess around with things like shells and tiling window managers. Others even return to Windowsland and instead focus all of their efforts on innovating at the highest levels of what they can do with C# and actually making money with an innovative business model.

But you'll never learn where you don't enjoy the thrill of seeing something new break on you if you don't have that initial "question everything" phase.

Personally I'd prefer to have to learn no shells at all, but since that's not possible I'll stick with the one that's most commonly installed, which is bash. Similar feeling with an editor - vanilla vi instead of learning and depending on a slew of fragile extensions that only work on a personal laptop. If the challengers supplant the defaults on servers in these domains at some point, I'll learn them then.
I don't think Fish counts as "new" at this point, given that it's been around for almost 20 years now. "Boutique", perhaps?
Just go for it. I've been using Fish as a daily driver for something like 14 or 15 years now. I have no regrets about it.

If I want it on a server I'm using, I (*gasp!*) just install it.

(I still write Bash sometimes and that's not really a problem, either.)

I feel like having ipython available whenever I feel like it from my shell is the best of both worlds
you can use both.

whenever I have some task to deal with data manipulation, i.e. fetch a json, map/filter/reduce on it, save it as some format, I reach for nushell.

If it's just process management or day to day trigger of command in a folder, I use zsh.