16 ms·
Nsh: A fish/bash-like Posix shell in Rust
- cogburnd02 5y agoJust a heads up: name collision with the default shell on (now Apache) Nuttx. http://nuttx.incubator.apache.org/docs/latest/applications/nsh/index.html http://nuttx.incubator.apache.org/docs/latest/applications/n...
- yewenjie 5y agoVery cool. I really love fish but sometimes find it very annoying to translate random posix snippets from the web.
- AYBABTME 5y agoThe 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)$
- jpambrun 5y agoI think you should hit ctrl+d when you are done in bash to avoid the nested fish>bash>fish.
- AYBABTME 5y agoThe 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.
- knjmooney 5y ago`exec <shell>` would avoid nested shells and inherit the environment. Which might be preferable if you find your terminal emulator complaining about processes still running on close.
- R0flcopt3r 5y agoOr just simply: (fish)$ bash -c ./random.sh
- gnubison 5y agoNo need to use -c there: (fish)$ bash random.sh
- AYBABTME 5y agoThat doesn't give you the env vars that the script might have set.
- pxc 5y agoYou 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/oh-my-fish/plugin-foreign-env https://github.com/edc/bass https://github.com/edc/bass
- stjohnswarts 5y agocould you explain this? How could the script set env vars before you run it??
- sjmulder 5y agoWould it be better to ‘exec’ the shells to avoid the nesting?
- rgoulter 5y agoHave you made use of tools like babelfish? https://github.com/bouk/babelfish https://github.com/bouk/babelfish
- socialdemocrat 5y agoUnless 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.
- markstos 5y agoWith Fish 3.0 and 3.1 it’s even more compatible with snippets you are likely to find to copy and paste. Do you remember something you found that doesn’t work?
- HMH 5y agoLooks 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 make more users happy as bash is so ubiquitous.
- sprash 5y ago> 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 https://github.com/akinomyoga/ble.sh
- ktm5j 5y agoTotally agree, but having used zsh, fish and elvish as my daily driver shell (each for at least 1 month) I think that not having POSIX/bash compliance eventually becomes an annoyance. I like zsh because it is mostly (entirely?) POSIX compliant, but adds extended features. I think that's the best approach to make it easier for people to start using your shell. random note: back when the Go language was first released I wanted to try it out.. I started making a shell that I called GoSH. Didn't get very far, you could execute programs, change directories etc. It was fun! And taught me a lot about low level languages.
- 5y ago
- shomyo 5y agoWow! Another piece of software written in Rust with hobby-level of usability.
- hnlmorg 5y agoThis 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/ https://www.oilshell.org/
- mongol 5y ago> Fish is really neat but I prefer old-fashioned, traditional, and ergonomic shell syntax. What does this really mean? Especially the ergonomic part?
- adrian_b 5y agoI do not know what was meant, but for example when I have looked at fish, I have seen some features that appeared to be nice, but also some gratuitous changes to the core shell syntax that were not improvements. For example, replacing "&&" and "||" with "and" and "or", is not an improvement. There are many other such changes that make the shell more verbose without bringing any advantage. This also happened with the C shell, csh, which introduced some convenient new features for interactive use, but it also included a large number of gratuitous changes in the syntax that were not improvements.
- ChrisSD 5y agoI find typing `&&` to be annoyingly difficult. I have to hold shift and hunt around for the `7` key (and probably hit `6` or `8` first). Whereas I can type "and" without looking or even really thinking about it.
- ridiculous_fish 5y agoNote fish supports "&&" and "||" as of version 3.0
- pxc 5y ago> some gratuitous changes to the core shell syntax that were not improvements > For example, replacing "&&" and "||" with "and" and "or", is not an improvement. There are many other such changes that make the shell more verbose without bringing any advantage. In Fish, `and` was never a synonym for `&&`, and `or` was never a synonym for `||`. Fish's use of `and` and `or` also did not introduce any syntax that you won't find in Bash and friends. `and` and `or` in Fish are _commands_, and they use the _pre-existing syntax_ for _normal commands_. This is absolutely an improvement, because it's strictly less syntax that allows you to do all of the same things with virtually no increase in the number of characters. `; or` is only a single character more than ` ||`, and `;or` is the same number of characters as ` ||`. This is a very bad example of ‘increased verbosity’.
- agluszak 5y agoThe name sounds very similar to Nushell[1], also written in Rust, but more mature and recognizable 1: https://www.nushell.sh/ https://www.nushell.sh/
- rurban 5y agoBut less compatible, which is the goal here. Being a practical shell to use
- Klasiaster 5y agoThere is also https://github.com/nixpulvis/oursh 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://www.shellcheck.net/ ² https://github.com/anordal/shellharden https://github.com/anordal/shellharden
- nixpulvis 5y agoI'm actually most interested in the UX around https://explainshell.com https://explainshell.com, but I haven't had the time to dig into it yet still.
- socialdemocrat 5y agoI 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.
- vmladenov 5y agoAs someone who stopped using fish, I found fzf to be more useful than fish’s history completion so it became less tolerable to have to type `env` in front of the bash oneliners our test runner puts out.
- ridiculous_fish 5y agoJust noting that fish supports the `var=val cmd` syntax starting in 3.1, so `env` shouldn't be necessary.
- jokethrowaway 5y agoI've used fish in the last few years and zsh before that. The experience out of the box (coupled with something like starship) is pretty good but I don't like the incompatibility with basic things, like $() vs (). I also find fish to be a bit on the slow side in some instances, so I think I'll keep tabs on nsh
- ridiculous_fish 5y agoNice! I see nsh uses threads internally. Any plans on how to handle the fork-thread interaction?
- implfuture 5y agoWill this support native windows? The main reason I have switched to nushell is because it is cross platform
- bscphil 5y ago> I don't need customizability Configuration isn't for you. It's for other people. Configuration is the part of a program that performs the function of making it useful for more than one person. It is the necessary glue that brings together many developers and many users into one project.
- preseinger 5y agoSoftware that requires configuration to be useful to more than one person has failed it's mandate in proportion to that configurability. It's precisely the opposite of necessary glue, it's duct tape: often the pragmatic choice, but almost always a sign of a design failure.
- laumars 5y agoWhat utter tosh. People have different preferences because people are different. If your point was apt then this submission wouldn’t exist because $SHELL wouldn’t be a configurable option in the first place.
- bscphil 5y agoPeople have different preferences, but moreover people have different needs. Configuration shouldn't be thought of as optional. If, as the parent comment says, settings are design failures, they arise from the fact that it's not possible to design software that works for everyone. To fix this problem you wouldn't have to design better software, you'd have to design a better human! Just to state the obvious examples, i18n is exposed through configuration, accessibility features are configurations. These aren't optional parts of a program that can simply be designed around. To be clear, I agree with you that human preferences are valid as such, just clarifying that your parent comment is profoundly wrong even if you think that all people ought to have the same preferences.
- preseinger 5y agoYes, ideally, there would be one shell used everywhere. Obviously!