Hacker News new | ask | show | jobs
by jhillyerd 3059 days ago
After using fish for 3 years, I'm finding there is very little reason to have my login shell maintain backwards compatibility with bash.

The only time I run into issues is when a command expects manipulate environment variables via bash syntax.

I think the fish documentation WRT to scripting could be much better, but the language is more elegant than bash or PowerShell IMHO.

5 comments

Interesting seeing so many fish fans. I absolutely love fish. It makes my everyday shell usage so much nicer. But it seems like a totally unknown shell to most people. I never see anybody else use it at any job I've had.

I did use fish a bit as a script language, but I decided for anything of any size I much prefer Julia. For typical file system navigation, fish is better, but Julia is actually pretty decent as a shell, despite being a real language. So writing shell scripts in it is pretty nice.

In the beginning I wrote separate programs executed from fish shell. But now I just fire up Julia as a shell and run functions directly there interactively.

I remember a few years ago poking at julia and thinking it would make a really good shell language. The thing that killed it for this use at the time was slow startup; is that better now?
Much better, it's certainly worth giving it another go. It's still much slower than Python, but it's quick enough that I don't notice it all.

  $ time julia -e 'println("Hi")'
  Hi

  real    0m0.241s
  user    0m0.216s
  sys     0m0.196s
  $ time python3 -c 'print("Hi")'
  Hi
  
  real    0m0.046s
  user    0m0.020s
  sys     0m0.000s
Inspired me to install and try; about 350ms on my macbook pro. Much better than it used to be, but still more than you'd want for everyday commands (at least if you're picky about having your computer feel responsive, which I am). :-)
I sort of agree that there isn't any strong reason for an interactive shell to have 100% bash compatibility. However, when I tried to convert to using fish I found my muscle-memory used too many simple history substitutions like "!!" and "!$" (which actually pre-date bash; they arrived with csh 40 years ago!) which were missing. Ultimately I gave up and went back to bash.

It sort of is an "uncanny valley" for a text interface. It feels close enough to a traditional UNIX shell that I start to interact with it like one... but has enough differences that I found myself constantly tripping over them.

It was difficult to implement !! and !$ in fish (I rarely actually used them in bash, so it wasn't an issue for me) and I know others who found that annoying. However if you dig around, there are a couple of solutions on Stack Overflow and blog posts that add in that functionality using plugins or functions. It's not exactly the same, but some of them work pretty well.
You may be underestimating the importance of these particular operators to experienced users. I at least would be very dissuaded from trying an alternate shell without a simple way to enable these.
I use !! maybe ten times per day. !$ can be implemented in your PS1 easily.
I used to. Now I just Ctrl-P.
> The only time I run into issues is when a command expects manipulate environment variables via bash syntax.

And in my experience 90% of those are in the form `FOO=bar command` which can be replaced with `env FOO=bar command` and works just fine in fish.

Both support for `&&` and `||` (instead of `and` and `or`) as well as supporting `FOO=bar command` are under consideration for fish 3.0 to ease the migration path. The former is pretty much going to happen, the latter if we get around to it, DV.
This would be much appreciated. I know there are a few people on my team that cam't use fish due to our npm scripts needing to be compatible with cmd
Why don’t your npm scripts specify /bin/sh as the interpreter?
Where things get problematic is with commands that send a set of environment variables to stdout, like

    eval $(ssh-agent)
Sure you can get addons (like bass[0]) that will translate the sh environment variable settings to fish, but it’s a pain to have to do that (and remember wth it was called).

[0] https://github.com/edc/bass

Non-bash compliant shells suck from the Google, copy, and it works perspective. I even shy away from using zsh because most setups assume bash.
Just launch a subshell and problem solved. I switch between zsh, bash, cmd, powershell quite frequently.
Same. The assumption that both types of users need to have their use case solved by the same language is foreign to me.

I use Fish as my shell, but I do scripting with Bash. There’s nothing that prevents you from doing so unless you’re sourcing a file.