News for hackers. Stuff that matters.
Re:New Features in the Fish Shell by maximilianroos on Tuesday September 29, 2020 @02:39PM (#24631377)
To preface — I love Fish — "Finally, a command line shell for the 90s" is an apt description. I use it every day.

But I haven't managed to recommend it to beginners. There are so many bash instructions out there, and translating between bash and fish isn't easy for a beginner.

That's a great shame and missed opportunity, because beginners would in particular value a nice shell. The shell is often one of the harder tools to learn — e.g. I find beginners are more comfortable in a Jupyter Notebook than they are the shell.

I'm not sure whether there's a way of combining fish's ease of use with a notion of compatibility — maybe a "bash mode" for beginners, which accepts bash commands? Or error messages which return translated commands?

(I recognize not all commands can be translated, but all of those that would be run by a beginner can be)

Re:New Features in the Fish Shell by chubot on Tuesday September 29, 2020 @04:37PM (#24632662)
This is the point of Oil -- having a smooth upgrade from bash. The interactive shell ended up being more work than I anticipated. So I'm looking for people who want to run with it either as a separate project or part of Oil.

http://www.oilshell.org/blog/2020/02/recap.html#fish-oil-is-...

Another option is to link Oil as a C++ library into another shell, which is starting to become possible. Oil handles all the difficult language and compatibility issues, and encapsulates them, so it's a great complement to someone who only wants to work on the interactive shell.

Even though it cleans up many legacy warts, Oil runs thousands of lines of real bash programs: https://github.com/oilshell/oil/wiki/Shell-Programs-That-Run...

Posts on the interactive shell: https://www.oilshell.org/blog/tags.html?tag=interactive-shel...

Re:New Features in the Fish Shell by hinkley on Tuesday September 29, 2020 @03:22PM (#24631845)
It's a chronic problem on work projects that people write shell scripts without a shebang operator at the top. Obscure error messages are usually how I find out someone is using zsh, fish, or some other shell.

I fix what I can, but it's like mopping up water during a rainstorm. Yes it's better than doing nothing, but also there will be more in twenty minutes so don't make any plans.

Re:New Features in the Fish Shell by azernik on Tuesday September 29, 2020 @05:44PM (#24633388)
One way I force people (mostly myself) to include shebang lines:

Have a scripts directory in my repo that mixes shell and python scripts with no file extensions and executable bits set. If I don't put a shebang, it just doesn't run.

Of course, this requires you to have firm control of code style policies.

Re:New Features in the Fish Shell by kstrauser on Tuesday September 29, 2020 @07:25PM (#24634239)
Make a post-commit hook that adds "#!/usr/bin/yes No." at the top of every file missing a shebang.
Re:New Features in the Fish Shell by azernik on Tuesday September 29, 2020 @09:53PM (#24635036)
Heh.
Re:New Features in the Fish Shell by maple3142 on Tuesday September 29, 2020 @10:15PM (#24635119)
But, does shebang works when you want to source some files?
Re:New Features in the Fish Shell by masukomi on Tuesday September 29, 2020 @10:36PM (#24635190)
you can source a file that contains a shebang in most (all?) shells assuming it contains code written in the same shell language. I.e. a bash file can't source a fish file and vice-versa.
Re:New Features in the Fish Shell by hinkley on Wednesday September 30, 2020 @01:02AM (#24635836)
Don’t cross the streams.

It would be bad.

Re:New Features in the Fish Shell by binaryanomaly on Tuesday September 29, 2020 @02:55PM (#24631549)
Just enter "bash" when you need bash and exit it once you're done. Barely need this but sometimes it's useful.

Fish imho offers superb usability, wouldn't want to miss it.

Re:New Features in the Fish Shell by lighthazard on Tuesday September 29, 2020 @03:26PM (#24631878)
You lose all the fish goodies when you do this, no?
Re:New Features in the Fish Shell by Zardoz84 on Tuesday September 29, 2020 @03:31PM (#24631934)
you only need to paste a line or two of bash. it's what I did when I have a problem with some online help that put a line that only works on bash
Re:New Features in the Fish Shell by riyadparvez on Tuesday September 29, 2020 @03:54PM (#24632191)
Some commands are compatible with bash, but not compatible with zsh. I do the same thing when using zsh.
Re:New Features in the Fish Shell by binaryanomaly on Tuesday September 29, 2020 @03:35PM (#24631971)
exactly.
Re:New Features in the Fish Shell by alan_n on Tuesday September 29, 2020 @03:45PM (#24632075)
I wish someone had recommended fish to me as a beginner. When I discovered it I was finally able to write some aliases and scripts without copy/pasting, overdoing it by resorting to a real programming language, or wasting an entire day trying then giving up. Concerning bash instructions, it's not that hard to translate them imo, or you can just use bass or just pop into bash for a second.
Re:New Features in the Fish Shell by duckerude on Tuesday September 29, 2020 @03:34PM (#24631962)
> Or error messages which return translated commands?

Fish does this in some cases:

  ~> echo $(true)
  fish: $(...) is not supported. In fish, please use '(true)'.
  echo $(true)
       ^
> (I recognize not all commands can be translated, but all of those that would be run by a beginner can be)

Not all of them, unfortunately.

Consider `while true; do something; done`. Fish interprets this as an unclosed while loop, where `do` and `done` are ordinary commands. So if you enter it you don't get a syntax error, fish just waits for more input until you enter `end`. The same goes for `if` and `for`.

Re:New Features in the Fish Shell by maximilianroos on Tuesday September 29, 2020 @07:48PM (#24634410)
Good point on the loop, I hadn't thought about that, thanks for correcting me.

On the error messages, I was thinking even clearer for beginners, giving them the whole statement, to avoid uncertainties around where the quotes should be included in '(true)'. Maybe even a shortcut to paste the corrected line in their terminal.

  echo $(true)
       ^
  fish: $(...) is not supported. In fish, please use '(true)', like:

  echo (true)

  Alt+r will insert this line in your terminal.
Re:New Features in the Fish Shell by pjmlp on Tuesday September 29, 2020 @02:52PM (#24631512)
Actually it is more "Finally, a command line shell for the 80s".

"Xerox Alto"

https://www.computerhistory.org/revolution/input-output/14/3...

Having grown through the UNIX adoption in the enterprise, it kind of feels ironic that nowadays bash is kind of seen as the UNIX shell, and in those days it was just one among many possibilities to configure on /etc/passwd

Re:New Features in the Fish Shell by snazz on Tuesday September 29, 2020 @02:59PM (#24631601)
Bash is definitely seen as the "Linux shell", but most users of non-Linux Unixes and Unix-likes don't use Bash. macOS, for instance, now uses Zsh out of the box (although most Bash one-liners still run unmodified in Zsh).

But Linux is the majority of the Unix-like market, so it (and therefore Bash) dominates.

Re:New Features in the Fish Shell by tssva on Tuesday September 29, 2020 @04:07PM (#24632325)
macOS just recently switched to zsh as the default and doesn't change the shell for existing users so I imagine it is likely the majority of macOS users are still using bash.
Re:New Features in the Fish Shell by snazz on Tuesday September 29, 2020 @04:09PM (#24632346)
True, although it gives you a pretty prominent notice that Zsh is now the preferred shell when you start Terminal for the first time after updating to Catalina.
Re:New Features in the Fish Shell by mixmastamyk on Tuesday September 29, 2020 @04:57PM (#24632880)
I think it's referencing the color support that didn't really hit until the 90s.
Re:New Features in the Fish Shell by zamadatix on Tuesday September 29, 2020 @02:42PM (#24631409)
Re:New Features in the Fish Shell by SAI_Peregrinus on Tuesday September 29, 2020 @03:01PM (#24631617)
Oil is more focused on making shell scripting nicer, Fish is more focused on making shell interaction nicer. Both are cool projects, just slightly different focus.
Re:New Features in the Fish Shell by oblio on Tuesday September 29, 2020 @03:37PM (#24631992)
If Oil makes error checking and error messages nicer, it will have provided an awesome service to the community.
Re:New Features in the Fish Shell by jiehong on Tuesday September 29, 2020 @02:42PM (#24631417)
Usually, those commands can be run in bash from fish with a bash -c, or from a file.
Re:New Features in the Fish Shell by SAI_Peregrinus on Tuesday September 29, 2020 @02:53PM (#24631522)
Or via Bass[1], for things that modify the environment.

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

Re:New Features in the Fish Shell by markstos on Tuesday September 29, 2020 @06:10PM (#24633625)
Extra compatibility has been added lately, like && and ||. More bash syntax Just Works now.

I think it's fair to say "If it doesn't work in fish, just type `bash` to enter a bash shell and try again."

Re:New Features in the Fish Shell by mxcrossb on Tuesday September 29, 2020 @07:56PM (#24634448)
I don’t think this is such a big deal. Every programmer needs to become sufficient in bash because odds are you’re going to log into another computer which only has bash or csh, and likely you need to modify someone’s bash script. It’s probably best for beginners to learn bash first, and for intermediate users to switch to fish once they understand the concepts.
Re:New Features in the Fish Shell by ilaksh on Tuesday September 29, 2020 @04:09PM (#24632349)
It actually doesn't come up that often. A lot of times you can just either A) paste one line at a time or B) use double quotes.

But what I do is I run fish manually on top of bash. If I have an issue, I just type exit and then try to paste the commands in again. Then when I am done I restart fish.

Re:New Features in the Fish Shell by Osiris on Tuesday September 29, 2020 @05:34PM (#24633293)
I found that adding the "&&" operator recently has fixed that for a lot of common cases. I still prefer the "; and" syntax though.