From d2e6e6b5de1d56d53aee2da81c2e9ee553971c72 Mon Sep 17 00:00:00 2001 From: arpitchakladar Date: Wed, 9 Sep 2026 23:29:20 +0530 Subject: refactor(modules): consistent message formats across all scripts --- modules/security/gopass/gopass-ssh-load.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'modules/security/gopass/gopass-ssh-load.sh') diff --git a/modules/security/gopass/gopass-ssh-load.sh b/modules/security/gopass/gopass-ssh-load.sh index b9a06e9..8c1b11f 100644 --- a/modules/security/gopass/gopass-ssh-load.sh +++ b/modules/security/gopass/gopass-ssh-load.sh @@ -28,11 +28,15 @@ set -o pipefail export GNUPGHOME="@@GNUPGHOME@@" export GOPASS_SSH_KEYS="@@GOPASS_SSH_KEYS@@" +info() { printf '\033[1;34m==>\033[0m %s\n' "$*"; } +warn() { printf '\033[1;33m==> warning:\033[0m %s\n' "$*" >&2; } +error() { printf '\033[1;31m==> error:\033[0m %s\n' "$*" >&2; } +die() { error "$*"; exit 1; } + SSH_AUTH_SOCK="$(gpgconf --list-dirs agent-ssh-socket)" export SSH_AUTH_SOCK if [ -z "$SSH_AUTH_SOCK" ] || [ ! -S "$SSH_AUTH_SOCK" ]; then - echo "Error: SSH_AUTH_SOCK is not set or valid." >&2 - exit 1 + die "SSH_AUTH_SOCK is not set or valid." fi if ssh-add -l 2>/dev/null | grep -qE "(ED25519|RSA|ECDSA)"; then @@ -41,8 +45,7 @@ fi # GOPASS_SSH_KEYS holds a space-separated list of gopass entry names under ssh if [ -z "${GOPASS_SSH_KEYS:-}" ]; then - echo "Error: GOPASS_SSH_KEYS is not set. Example: GOPASS_SSH_KEYS=\"github gitlab\"" >&2 - exit 1 + die "GOPASS_SSH_KEYS is not set. Example: GOPASS_SSH_KEYS=\"github gitlab\"" fi # shellcheck disable=SC2086 @@ -63,6 +66,6 @@ for key in "${keys[@]}"; do ssh-add "$keyfile" 2>/dev/null rm -rf "$tmpdir" else - echo "Warning: no gopass entry ssh/$key" >&2 + warn "no gopass entry ssh/$key" fi done -- cgit v1.2.3