From ea25ccf62c583f7fac45cfdff941c78c8b05666a Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Sun, 5 Oct 2014 21:46:58 -0400 Subject: [PATCH] Set default GPG_AGENT_PID for grep If `GPG_AGENT_PID` is unset, grep will succeed if another gpg-agent is running as it will match the string `gpg-agent` where the PID was an empty string. Set a default value for grep to a value that will never match if unset, i.e. -1. --- modules/gpg/init.zsh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/gpg/init.zsh b/modules/gpg/init.zsh index 48f1715..cb78495 100644 --- a/modules/gpg/init.zsh +++ b/modules/gpg/init.zsh @@ -15,7 +15,7 @@ _gpg_agent_conf="$HOME/.gnupg/gpg-agent.conf" _gpg_agent_env="${TMPDIR:-/tmp}/gpg-agent.env" # Start gpg-agent if not started. -if ! ps -U "$USER" -o ucomm | grep -q gpg-agent; then +if ! ps -U "$USER" -o pid,ucomm | grep -q -- "${GPG_AGENT_PID:--1} gpg-agent"; then eval "$(gpg-agent --daemon | tee "$_gpg_agent_env")" else # Export environment variables.