add friendlier error message in the event of no identity

fixes #6
This commit is contained in:
Ryan Mulligan 2020-12-18 19:57:48 -08:00
parent be7bad2c12
commit de625b5298

View file

@ -111,6 +111,10 @@ function edit {
if [ -f "$HOME/.ssh/id_ed25519" ]; then if [ -f "$HOME/.ssh/id_ed25519" ]; then
DECRYPT+=(--identity "$HOME/.ssh/id_ed25519") DECRYPT+=(--identity "$HOME/.ssh/id_ed25519")
fi fi
if [[ "''${DECRYPT[*]}" != *"--identity"* ]]; then
echo "No identity found to decrypt $FILE. Try adding an SSH key at $HOME/.ssh/id_rsa or $HOME/.ssh/id_ed25519 or using the --identity flag to specify a file."
exit 1
fi
DECRYPT+=(-o "$CLEARTEXT_FILE" "$FILE") DECRYPT+=(-o "$CLEARTEXT_FILE" "$FILE")
${ageBin} "''${DECRYPT[@]}" || exit 1 ${ageBin} "''${DECRYPT[@]}" || exit 1
cp "$CLEARTEXT_FILE" "$CLEARTEXT_FILE.before" cp "$CLEARTEXT_FILE" "$CLEARTEXT_FILE.before"