1
0
Fork 0
mirror of https://github.com/Mic92/sops-nix.git synced 2025-03-16 21:48:15 +00:00

Fix sops-pgp-hook erroring in a strict shell

This commit is contained in:
Nicolas Berbiche 2021-02-08 15:49:30 -05:00
parent c3d43f833b
commit a3b53c6087
No known key found for this signature in database
GPG key ID: FA5696EDF35DA0B6

View file

@ -5,20 +5,20 @@ _sopsAddKey() {
fpr=$(@gpg@ --with-fingerprint --with-colons --show-key "$key" \ fpr=$(@gpg@ --with-fingerprint --with-colons --show-key "$key" \
| awk -F: '$1 == "fpr" { print $10; exit }') | awk -F: '$1 == "fpr" { print $10; exit }')
if [[ $fpr != "" ]]; then if [[ $fpr != "" ]]; then
export SOPS_PGP_FP=''${SOPS_PGP_FP}''${SOPS_PGP_FP:+','}$fpr export SOPS_PGP_FP=''${SOPS_PGP_FP-}''${SOPS_PGP_FP:+','}$fpr
fi fi
} }
sopsPGPHook() { sopsPGPHook() {
local key dir local key dir
for key in $sopsPGPKeys; do for key in ${sopsPGPKeys-}; do
if [[ -f "$key" ]]; then if [[ -f "$key" ]]; then
_sopsAddKey "$key" _sopsAddKey "$key"
else else
echo "$key does not exists" >&2 echo "$key does not exists" >&2
fi fi
done done
for dir in $sopsPGPKeyDirs; do for dir in ${sopsPGPKeyDirs-}; do
while IFS= read -r -d '' key; do while IFS= read -r -d '' key; do
_sopsAddKey "$key" _sopsAddKey "$key"
done < <(find -L "$dir" -type f \( -name '*.gpg' -o -name '*.asc' \) -print0) done < <(find -L "$dir" -type f \( -name '*.gpg' -o -name '*.asc' \) -print0)