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

Re: encryption



On 4/21/2018 9:58 PM, David Christensen wrote:
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.


Thanks David, for pointing out that bit of code won't work in Dash!

That's one of the reasons I have redone all of my scripts to have them POSIX compliant while keeping portability a priority! :)

I only speak shell scripting, how would you do that in Perl?

--
John Doe


Reply to: