[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: encryption



On 04/21/18 08:38, john doe wrote:
Here's the code I used to let a script prompt for a password:

read -s -p "Enter password: "
[ $? -ne 0 ] && exit 1

Note that the above 'read' command will operate differently on Dash and on Bash:

2018-04-21 12:53:27 dpchrist@vstretch ~/sandbox/sh
$ cat read
read -s -p "Enter password: "
[ $? -ne 0 ] && exit 1
echo
echo $REPLY

2018-04-21 12:54:03 dpchrist@vstretch ~/sandbox/sh
$ dash read
read: 1: read: Illegal option -s

2018-04-21 12:54:06 dpchrist@vstretch ~/sandbox/sh
$ bash read
Enter password:
secret


Shell scripts using lowest-common denominator Bourne shell syntax are the most portable. When I start getting fancy with Bash, I switch to Perl.


David


Reply to: