Read in password instead of providing an argument

This commit is contained in:
RealStickman 2021-07-12 08:25:06 +02:00
parent 4359dfa302
commit 3e1fcedbb3
2 changed files with 10 additions and 4 deletions

View File

@ -1,6 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
: '
# give password as argument # give password as argument
if [ $# -eq 1 ]; then if [ $# -eq 1 ]; then
pass=$1 pass=$1
@ -11,14 +12,12 @@ else
echo "Please only insert one argument" echo "Please only insert one argument"
$(exit 1); echo "$?" $(exit 1); echo "$?"
fi fi
'
# TODO make this work
: '
# prompt for password # prompt for password
echo -n Password: echo -n "Password: "
read -s -r pass read -s -r pass
echo echo
'
# go to home dir # go to home dir
cd "$HOME" cd "$HOME"

View File

@ -1,6 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -euo pipefail set -euo pipefail
: '
# give password as argument # give password as argument
if [ $# -eq 1 ]; then if [ $# -eq 1 ]; then
pass=$1 pass=$1
@ -11,6 +12,12 @@ else
echo "Please only insert one argument" echo "Please only insert one argument"
$(exit 1); echo "$?" $(exit 1); echo "$?"
fi fi
'
# prompt for password
echo -n "Password: "
read -s -r pass
echo
# go to home dir # go to home dir
cd "$HOME" cd "$HOME"