fixed bug with creating entries

This commit is contained in:
Dylan Araps 2019-02-24 23:53:39 +02:00
parent c94a4a2b13
commit 8e6ad80c4d

8
pash
View File

@ -20,8 +20,9 @@ pw_add() {
die "Failed to generate a password." die "Failed to generate a password."
# Handle category in store name. # Handle category in store name.
[[ $1 == */* ]] && [[ $1 == */* ]] && {
mkdir -p "${1%/*}" || die "Couldn't create category '${1%/*}'." mkdir -p "${1%/*}" || die "Couldn't create category '${1%/*}'."
}
gpg2 -co "$1.gpg" <<< "$password" gpg2 -co "$1.gpg" <<< "$password"
} }
@ -58,12 +59,11 @@ pw_gen() {
# data from '/dev/urandom' to meet the length requirement. # data from '/dev/urandom' to meet the length requirement.
# example: 50 lines from /dev/urandom == 50 char password # example: 50 lines from /dev/urandom == 50 char password
mapfile -tn "${length:=50}" rand </dev/urandom mapfile -tn "${length:=50}" rand </dev/urandom
password=${rand[*]}
[[ $plain ]] && [[ $plain ]] &&
password=${password//[^[:alnum:]]} glob=[:alnum:]
password=${password//[^[:graph:]]} password=${rand[*]//[^${glob:-[:graph:]}]}
password=${password:0:$length} password=${password:0:$length}
} }