Skip to main content
2 of 3
grammar
Hey
  • 691
  • 9
  • 20

Ask for a password in POSIX-compliant shell?

When I want to ask for a password in a bash script, I do that :

read -s

...but when I run bash in POSIX mode, with sh, the -s option is rejected:

$ read -s
sh: 1: read: Illegal option -s

How do I securely ask for an input with a POSIX-compliant command ?

Hey
  • 691
  • 9
  • 20