fix printing multiple word field names with spaces

This commit is contained in:
Joel Beckmeyer 2021-07-13 21:43:09 -04:00
parent e4e520f6f6
commit 40837d70af

View File

@ -39,7 +39,7 @@ _pass_field() {
IFS=$'\n'
plaintext="$(pass show $password | tail -n +2)"
for line in $plaintext; do
if [[ $line == $1:* ]]; then
if [[ $line =~ ^${1}:* ]]; then
printf "$(_trim "$(printf "$line" | cut -d: -f1 -s --complement)")"
fi
done
@ -52,7 +52,7 @@ _pass_get() {
elif [[ $1 == "OTP" ]]; then
pass otp "$password" | tail -n1 | { IFS= read -r pass; printf %s "$pass"; }
else
printf "$(_pass_field $1)"
printf "$(_pass_field $*)"
fi
}