Skip to content
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

Stdin should be an error on platforms that don't support it #21

Open
back2dos opened this issue Mar 6, 2017 · 4 comments
Open

Stdin should be an error on platforms that don't support it #21

back2dos opened this issue Mar 6, 2017 · 4 comments

Comments

@back2dos
Copy link
Member

back2dos commented Mar 6, 2017

Followup on #18

@kevinresol
Copy link
Member

kevinresol commented Mar 15, 2017

Was thinking how to deal with haxetink/tink_cli#2, is it possible that tink_io provide some sort of "secureStdin" which will not echo user's input to the screen?

The haxelib implementation is here.

@back2dos
Copy link
Member Author

My advice: don't follow that path, for at its end lies only madness! :D

In essence Sys.getChar(false) is a lot different from reading from stdin. It puts the input stream into raw mode, assuming it's a tty (TeleTYpewriter) stream, in which case you can read raw keystrokes (so Ctrl+C won't send a SIGTERM but rather an ASCII control sequence - which is why you can't exit in haxelib's password prompt). The docs of node's tty module explain that. So for example if you pipe a file into a process it's not a tty stream, so you can't set it to raw mode.

If you still want to plunge into this, I suggest having a look at node's readline module that can be used for password input as discussed here: http://stackoverflow.com/questions/24037545/how-to-hide-password-in-the-nodejs-console

@kevinresol
Copy link
Member

I suggest having a look at node's readline module

Yay I just read that. I think I have an idea now. So basically it is just reading the stdin one byte at a time and write some escape sequences to stdout to wipe out the stuff.

@kevinresol
Copy link
Member

kevinresol commented Mar 15, 2017

But I am afraid the escape sequence won't work on windows cmd prompt. Have to test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants