Re:Nsh: A fish/bash-like Posix shell in Rust
by yewenjie on Saturday October 23, 2021 @08:05AM
(#28967633)
Very cool. I really love fish but sometimes find it very annoying to translate random posix snippets from the web.
[ Parent
| on HN ]
Re:Nsh: A fish/bash-like Posix shell in Rust
by AYBABTME on Saturday October 23, 2021 @09:06AM
(#28968022)
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)$
Re:Nsh: A fish/bash-like Posix shell in Rust
by jpambrun on Saturday October 23, 2021 @09:11AM
(#28968056)
I think you should hit ctrl+d when you are done in bash to avoid the nested fish>bash>fish.
Re:Nsh: A fish/bash-like Posix shell in Rust
by AYBABTME on Saturday October 23, 2021 @09:20AM
(#28968128)
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
by knjmooney on Saturday October 23, 2021 @07:05PM
(#28973245)
`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.
Re:Nsh: A fish/bash-like Posix shell in Rust
by sjmulder on Saturday October 23, 2021 @01:36PM
(#28970562)
Would it be better to ‘exec’ the shells to avoid the nesting?
Re:Nsh: A fish/bash-like Posix shell in Rust
by R0flcopt3r on Saturday October 23, 2021 @09:13AM
(#28968076)
Or just simply:
(fish)$ bash -c ./random.sh
Re:Nsh: A fish/bash-like Posix shell in Rust
by AYBABTME on Saturday October 23, 2021 @09:18AM
(#28968114)
That doesn't give you the env vars that the script might have set.
Re:Nsh: A fish/bash-like Posix shell in Rust
by pxc on Saturday October 23, 2021 @10:45AM
(#28969018)
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
Re:Nsh: A fish/bash-like Posix shell in Rust
by stjohnswarts on Saturday October 23, 2021 @06:56PM
(#28973190)
could you explain this? How could the script set env vars before you run it??
Re:Nsh: A fish/bash-like Posix shell in Rust
by gnubison on Saturday October 23, 2021 @04:33PM
(#28971973)
No need to use -c there:
(fish)$ bash random.sh
Re:Nsh: A fish/bash-like Posix shell in Rust
by rgoulter on Saturday October 23, 2021 @09:42AM
(#28968352)
Have you made use of tools like babelfish? https://github.com/bouk/babelfish
Re:Nsh: A fish/bash-like Posix shell in Rust
by markstos on Saturday October 23, 2021 @08:34PM
(#28973761)
With 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?
Re:Nsh: A fish/bash-like Posix shell in Rust
by socialdemocrat on Saturday October 23, 2021 @12:19PM
(#28969881)
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.