-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
unix: difference to CPython when catting script into stdin #1306
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
Comments
Sounds good, isatty(), etc. |
It'll break all tests in tests/cmdline... but I'm prepared to deal with that :) |
Ok, it's pretty trivial to implement this using the following: if (!isatty(0)) {
do_file("/dev/stdin");
} But that probably won't work on windows... does windows have isatty? I'm pretty sure it doesn't have /dev/stdin :) Other option that will work on windows is to make a new wrapper for the lexer to init a file from a file descriptor. But that adds bulk. @stinos any suggestions? |
Windows has isatty() and it works fine as far as I can tell. |
I would be inclined to make lexer_from_fd and have it also take a filename argument for error reporting purposes. Then you can use stdin or pipes or whatever. Make the existing lexer function open the file and pass the filename in. Hardly adds any extra code. |
I agree with @dhylands to provide a way to open directly a file descriptor. |
Implemented. |
In CPython you can cat the script into stdin:
This works as expected. In uPy if you do this then it enters the REPL and the stdin data is interpreted at the REPL.
I think we should follow CPython here. It's more unixy.
The text was updated successfully, but these errors were encountered: