Live data from Hacker News

Nsh: A fish/bash-like Posix shell in Rust

github.com

11–20 of 56 posts

Re: Nsh: A fish/bash-like Posix shell in Rust

#11
post #7
post #6

Earlier quoted context omitted.

The trick is to enter bash from fish, run your command, and then call fish again. (fish)$ bash (fish>bash)$ source ./random.sh (fish>bash)$ fish (fish>bash>fish)$

I think you should hit ctrl+d when you are done in bash to avoid the nested fish>bash>fish.

The idea is to return to a fish shell, but with all the env-vars that bash might have loaded as a result of executing the script.

Re: Nsh: A fish/bash-like Posix shell in Rust

#12
post #4
post #3

Looks like the goal of this project is to be a replacement for bash with improved interactivity. That seems reasonable, compared to what you can do with zsh or fish bash is far behind concerning interactivity. While I personally think shells that abandon POSIX/bash compliance are much more interesting as those can implement a sane scripting language, sticking with bash but improving interactivity is probably going to…

> bash is far behind concerning interactivity. Is it really? Projects like ble.sh [1] seem to pull off advanced features like syntax highlighting and enhanced completion with pure bash without the need for reimplementing a whole shell from the ground up. 1.: https://github.com/akinomyoga/ble.sh

Wow, that looks amazing! Especially being implemented in pure bash!

Re: Nsh: A fish/bash-like Posix shell in Rust

#14
This project looks very young. It might evolve into a contender but even the document on Bash compatibility just says "TODO" and frankly Bash compatibility is going to be a multi-year project on its own.

For anyone after an upgrade path from Bash/Zsh then Oil shell is a lot more mature: https://www.oilshell.org/

Re: Nsh: A fish/bash-like Posix shell in Rust

#17

Earlier quoted context omitted.

Or just simply: (fish)$ bash -c ./random.sh

That doesn't give you the env vars that the script might have set.

You can use fenv or bass for that. They run a snippet or script of bash in bash, then import all the environment changes for you

https://github.com/oh-my-fish/plugin-foreign-env

https://github.com/edc/bass

Re: Nsh: A fish/bash-like Posix shell in Rust

#18
There is also https://github.com/nixpulvis/oursh which wants to be POSIX compatible with its own extensions. Actually I would prefer if a new shell focuses on bash compatibility.

If features are integrated, then I would probably want to have something about error handling because it is difficult to get right in bash even with shellcheck¹ plus shellharden², and gets just worse when things run in parallel.

¹ https://www.shellcheck.net/

² https://github.com/anordal/shellharden

Re: Nsh: A fish/bash-like Posix shell in Rust

#19
I have used fish for years, it is just painful to watch how other people work with old fashion shells.

I applaud this project for bringing fish goodness to more people, although I don’t quite get why people cannot just learn fish. Fish is very simple. There is not that much to learn.

Maybe it matters if your write a lot of shell scripts but for anything complicated I use Julia, Python, Go or some other more proper language.

To me shells are mainly for interactive work and really simple scripts without control flow, beyond perhaps a for loop.

Re: Nsh: A fish/bash-like Posix shell in Rust

#20
post #2

Very cool. I really love fish but sometimes find it very annoying to translate random posix snippets from the web.

Unless it is really simple stuff why not just drop temporarily into bash?

I mainly use fish for interactive work not for programming. Then I use a real programming language.

Post reply on HN