-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
Port stdin to lua's stdin #18
Comments
So with a little more read-into the code, I discovered puc-lua does infact use However, good news. By processing the stdin input first, you can define the rule of 'tty doesnt work when piping, even if the code Once tty is re-enabled, the pipe stdin will not give its data to the tty stdin. This creates the problem at when do I re-enable tty. This breaks As soon as I can figure this situation out, the ability to pipe data into lua rather than as a file for LuaConsole will be added. |
The need to store the file or be switched is irrelevant because it can be piped directly to lua via a function provided by lua. However, reinstating the data pipeline is a must for new data and will take some time to figure out how to do that. |
Lua5.1, Lua5.2, and Lua5.3 currently has no way of getting stdin input outside of manual in-console input. No matter what you pipe to luaw or lua, nothing actually gets sent to io.stdin for in-script use. In a recent update, I made it enabled to where you can use | and < to send files and strings to the program via stdin. I don't think I really set it up too good, but it works and I have a patch that I am working out at the time of writing.
The patch comes down to when what runs.
ARGS.restore_console
exists because I need to flag to re-enable tty for the post-exist flag -p. I will not be able to get stdin into my program and use -p without the hack, as this is due to Windows and Linux. It was a nasty hack that goes against the prettiness of the code I have, but hey. The hack has to do with organizing this process to allow tty to be reenabled and also be able to give scripts their data they want. Without the organization patch, piping and trying to -e a string will not work per trying toio.stdin:read()
due to when the hack comes into effect.More importantly though, Lua's code in liolib.c, if I am not mistaken, opens up 2 new files and treats them as a high level stdin and stdout. Using getc will allow for this ofc... you don't have to use the stdin file handle, in factecho print('hi') | lua -i
breaks in puc-lua the same way it does LuaConsole.... thus the hack I just brought up. Although, the cutesy that the puc-lua console is, it actually just executes whatever you pipe through it aka autodetection. Limiting, I know.Lua kindly puts the files in the registry. So sweet of them, I think I might as well take the files for myself and fix the pipeline on user switch request. Idk if it will break the io lib. If it does I can use other synthetic ways I am sure.Although, its good to keep in mind that people are definitely now allowed to pipe streams to the program - in that 'stdin' could not be used for processing socket streams of data at varying intervals. I don't want to create an io library lol.The text was updated successfully, but these errors were encountered: