<commit_before># Based on ssh-agent code

local GPG_ENV=$HOME/.gnupg/gpg-agent.env

function start_agent {
  /usr/bin/env gpg-agent --daemon --enable-ssh-support --write-env-file ${GPG_ENV} > /dev/null
  chmod 600 ${GPG_ENV}
  . ${GPG_ENV} > /dev/null
}

# Source GPG agent settings, if applicable
if [ -f "${GPG_ENV}" ]; then
  . ${GPG_ENV} > /dev/null
  ps -ef | grep ${SSH_AGENT_PID} | grep gpg-agent > /dev/null || {
    start_agent;
  }
else
  start_agent;
fi

export GPG_AGENT_INFO
export SSH_AUTH_SOCK
export SSH_AGENT_PID

GPG_TTY=$(tty)
export GPG_TTY
<commit_msg>Disable ssh-agent support if another ssh-agent is already running.<commit_after>local GPG_ENV=$HOME/.gnupg/gpg-agent.env

function start_agent_nossh {
    eval $(/usr/bin/env gpg-agent --daemon --write-env-file ${GPG_ENV}) > /dev/null
    export GPG_AGENT_INFO
}

function start_agent_withssh {
    eval $(/usr/bin/env gpg-agent --daemon --enable-ssh-support --write-env-file ${GPG_ENV}) > /dev/null
    export GPG_AGENT_INFO
    export SSH_AUTH_SOCK
    export SSH_AGENT_PID
}

# make sure all created files are u=rw only
umask 177

# source settings of old agent, if applicable
if [ -f "${GPG_ENV}" ]; then
  . ${GPG_ENV} > /dev/null
fi

# check for existing ssh-agent
if ssh-add -l > /dev/null 2> /dev/null; then
    start_agent_nossh;
else
    start_agent_withssh;
fi

GPG_TTY=$(tty)
export GPG_TTY

{'fraction_non_alphanumeric': 0.12936046511627908, 'fraction_numerical': 0.005087209302325582, 'mean_word_length': 3.5, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3817084', 'n_tokens_mistral': 563, 'n_tokens_neox': 535, 'n_words': 132}