How to make CLI password masking in Lua? E.g. when I write password it changes into asterisk or nothing is shown at all? I need platform-independent solution as my script will be used in Java application.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In plain Lua, the answer is simple: you can’t.
Since Lua is written in ANSI C you can not get characters from the command line without having to press enter. You can however make use of bindings to libraries like curses.lua which comes with luaposix.
Or if you can assume you’ll have an ANSI VT, you can resort to a hack like this:
More info about ANSI terminal control
But if it’ll be used for a Java application, why not use Java for the password prompt. I guess their support and control of the cli would be better and cross-platform…