I noticed fish has:
* extensive syntax highlighting
* "global" variables shared by all instances of fish, persisting past reboots.
what are other important features?
I noticed fish has:
* extensive syntax highlighting
* "global" variables shared by all instances of fish, persisting past reboots.
what are other important features?
I've considered switching from bash to fish (something I never did with zsh). The main reason I didn't is Stockholm syndrome, or that I'm too used to bash by now.
I think you can get zsh to do most of what fish does out of the box. If bash is Ed, it feels zsh is emacs and fish is (neo)vim.
Zsh is huge and I always get a bit of a panic attack when someone has given me a ssh login with zsh as the default shell. And an irrational urge to maul a unicorn.
With fish, it feels more like a friend went and tidied up your apartment just to be nice.
I guess I'm so used to bash, that the limited support that comes from completions is enough - and I end up writing a bit of documentation and automation, and work on "foreign" (other people's) servers - and it helps me to work in a posix shell for that reason - with fewer surprises.
You might even find that fish does out of the box something bash (now) can too - just isn't enabled by default or in typical distribution's configs.
Ymmv - it's worth testing imnho. And more interesting than zsh, which just feels like someone was bored in it class in high school and added colors and tinkered with the prompt, and tried à million different ideas - but never really liked working in shell.
I would have thought fish=emacs and zsh=vim in this analogy, since fish isn't really compatible with bash but zsh is?
$ wc -l ./.profile ./.vim/vimrc
249 ./.profile
173 ./.vim/vimrc
422 total
...but I probably just forgot that I'm an outlier:)For a similar reason, command substitution only splits on newlines. Unfortunately, some commands like pkg-config assume that the shell splits on regular spaces so you will need to use workarounds like (pkg-config | string split "")
That's not true. There are a few other shells out there that do. The issue is the popular shells tend to be the ones that go for POSIX (or Bash) compatibility and those that do go for a syntax redesign (for example) often get criticised for not being POSIX compatible. There is comment further down in this discussion describing those syntax differences as "bugs" rather than "features"; which just goes to demonstrate how ingrained Bash et al are to Linux/UNIX command line users.
Personally I see Fish and other non-POSIX shells like another programming language (arguably that's literally what they are). So switching from Bash to Fish - or whatever else - should be like switching from C++ to C#, Java, Rust, whatever. Sure there will be a lot of commonalities but it is the differences what makes the shift worthwhile.
That all said, I can't blame people for preferring a POSIX or Bash compatible shell because that's what you'd expect to find on any Linux or UNIX system. Or at the very least a Bourne Shell (sh). Plus most documentation online will be tailored for compliant shells. However it does become a self-fulling prophecy where compliant shells are more widely used because they're already more widely used. I'm fine with this though. People who want to make the shift and learn something new can still do so under the knowledge that they're breaking from the norms and all the potential complications that might bring; and people who just want something that's universal and works - irrespective of it's warts - can continue to do so.
I don't understand why your being standoffish over a technicality.
I’m just pointing out that this has literally zero whatsoever to do with the shell. You posted it as a comment in an article involving a choice of shells.
How am I being standoffish?
Coincidentally, this is what I'm working on with my shell.
The standard byte streams are just 3 file descriptors and on Linux are generally symlinks inside /proc but all that is handled by the pipe syscall (as you stated). However there is still a lot of code between the shell parsing your entered command line and pipe() being called and how the shell decides to implement fork() and pipe() is largely down to the shell designers. Going back to my earlier point about POSIX shells, there is a general expectation that these kinds of shells should just fork() and pipe(); which makes sense when you think about their heritage but it does allow developers to get creative if you're intending to break POSIX.
For example they could check the receiver processes for a signature (magic byte or something) to see if it's a supporting tool and if it is, the shell could then "man in the middle" the pipe; where it sets itself as the destination pipe for the first process and the source for the second process (eg `ls | grep foo` would be called as `ls | shell | grep`). That way the shell could then wrap STDOUT from `ls` up inside a more complex object and pass that to `grep`...and only do all this if `grep` already appears to support this new shell's object system.
Other ideas is that type information could be passed via a fourth file descriptor, UNIX socket or over a localhost TCP/IP listener. Or maybe you don't support smart processes and instead write your shell to do some of the heavy lifting instead via shell builtins (like how Bash has a few builtin functions) where you could write smarter data wrangling tools so it doesn't matter what crap `ls` or `grep` throw at you because you can pipeline that into a shell builtin.
This last approach of smarter builtins is the direction I took with my own hobby shell but I'm now looking for ways to pass that data type information along to other processes without breaking non-supporting processes.
I'm half asleep at the moment so probably haven't don't a good job explaining my thought process but there are a few of use playing around writing "alternative shells" (for want a better description).
It could be if it captured stdout of processes it launches.
Of course, the program would have to output a structured format that the shell recognized to provide the shell the option to do what is described upthread, so legacy programs wouldn't fit in well with it unless the shell was programmed with how to extract structured data from their unstructured output.
eg it could describe the data as a JSON array and the next command would grep through the elements rather than lines.
But I think it has a bit of a learning curve because not thinking in string outputs is quite different.
A lot of things are even defined as ordinary fish functions. In sh, aliases are a dark and evil feature that hooks into the parser and can be used to create rudimentary macros. They have some really surprising behavior. But in fish, `alias` is a shell function and you can get the complete source code on your screen by running `type alias`. It doesn't do any evil things because it can only do things you could do yourself.
Fish has sensible variables and arrays. All variables can be arrays. When unquoted, variables expand like "$@" in sh, so packing multiple arguments inside a variable is trivial and there's no need to worry about whitespace. Command output splits on newlines, which means that things like `for file in (find . -iname 'foo')` just work, assuming you don't have newlines in your filenames.
Writing one-liners in fish makes me much less anxious then doing so in sh.
Though I'll say up front, again as a casual user, I'm not sure exactly how fish accomplishes making me more productive than bash. I'm also don't know if I ought to switch to something like zsh. I often read folks saying great things about zsh but it seems more like something aimed at "power users" and that ain't me.