1
0
mirror of https://github.com/dcarrillo/prezto.git synced 2024-12-22 08:08:00 +00:00

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.
This commit is contained in:
Sorin Ionescu 2014-10-05 21:46:58 -04:00
parent 3e88b8bcdc
commit ea25ccf62c

View File

@ -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.