-
-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide an API to evaluate code in a subinterpreter #704
Comments
@akinomyoga This is something I've been thinking about, since Python is developing it. https://lwn.net/Articles/754162/ -- Subinterpreter support for Python https://www.python.org/dev/peps/pep-0554/ Use cases:
Maybe with:
Still up for discussion. |
Oh, I see. Thank you! I was actually wondering what is "multiple interpreters", but I got it now! |
Actually there are two kinds of subinterpreters I can think of:
The first one is straightforward and almost done even, because of recent refactorings. The second one is a little more speculative, but could be useful. But the interpreter is designed to be very modular so things like this are possible. It should also help with porting to Windows or WebAssembly (WASI). I just separated all the code that starts processes into Anyway this is just saying that Oil can do stuff that other shells can't... It's far in the future but I think it will prove useful. Another project to illustrate that is "deno". One of the regrets by the creator of node.js is that they didn't preserve the security properties of v8. Basically v8 already has "subinterpreters" but the way that node uses v8 throws that away. So deno is another embedding of v8 that retains the sandbox. So Oil will have a sandbox, which is unlike any other shell. I think that will be useful for evaluating config files and as you point out writing a shell UI in "user space" -- you want to keep all the internal variables and functions separate from the user's program. https://dev.to/nickytonline/10-things-i-regret-about-nodejs-14m3 |
Relevant details on debugger support from Rocky Bernstein:
https://github.com/rocky/zshdb/blob/master/lib/save-restore.sh
https://github.com/rocky/zshdb/blob/master/lib/journal.sh |
Also mentioned on that thread: https://www.manpagez.com/man/1/ksh/
And
|
Use case: handling signals in shell scripts, to emulate what GNU readline does? We don't want to mess up the user signal state?
|
Very related: Child interpreters in Tcl: https://www.tcl.tk/man/tcl8.5/tutorial/Tcl43.html
|
ble.sh
also restores and saves many other shell settings before and after the execution of user commands (includingstty
,set -exvu -o posix -o emacs -o vi
,shopt -s nocasematach
,IGNOREEOF
,IFS
,BASH_REMATCH
,FUNCNEST
,$?
,$_
, etc.). Maybe it is better to provide command execution in an independent environment but not in a global context shared with the line editor (like JavaScript object trees in different pages in a browser).Also, I think we may consider the separation of the execution environment of the line editor and the user commands.
ble.sh
is completely implemented in a user space, so it provides complete flexibility allowing users to change any part ofble.sh
by shell scripts. But this flexibility is a double-edged sword. It is possible to completely breakble.sh
session by overwriting the shell functions ofble.sh
. Also,ble.sh
pollutes the shell variable namespace by defining a bunch of shell variables named_ble_*
. Maybe it is useful to provide some mechanism to protect/separate several execution environments as well as a special way of defining shell variables/functions in an environment from another environment.Note: But
ble.sh
is not implemented in that way, so the execution environment separation would be only useful for implementing entirely new line editors.from #653
The text was updated successfully, but these errors were encountered: