Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

read: Illegal option -s in shell scripting

Tags:

bash

shell

I tried running this code:

#!/bin/bash
read -s "Password: " password

With command:

run sh init.sh

it throws an error: read: Illegal option -s. Any help.

like image 1000
Vicky Avatar asked Mar 25 '16 06:03

Vicky


1 Answers

I take it you're using Debian/Ubuntu, or a BSD-derivative?

When you execute a command like run sh init.sh (although I'm not myself familiar with this run command) you are overriding the #!/bin/bash shebang. In your case sh is a strictly compliant POSIX shell like dash, where, in fact, the only argument to read that is not an extension is -r.

So maybe you'd want to use run bash init.sh instead?

like image 72
Geoff Nixon Avatar answered Nov 14 '22 04:11

Geoff Nixon