diff options
Diffstat (limited to 'pull.sh')
-rwxr-xr-x | pull.sh | 30 |
1 files changed, 24 insertions, 6 deletions
@@ -6,6 +6,23 @@ script_dir="$( dirname -- "${BASH_SOURCE[0]}" )" script_dir="$( cd -- "$script_dir" && pwd )" readonly script_dir +dump() { + local prefix="${FUNCNAME[0]}" + [ "${#FUNCNAME[@]}" -gt 1 ] && prefix="${FUNCNAME[1]}" + + local msg + for msg; do + echo "$prefix: $msg" + done +} + +check_ssh_agent_running() { + if [ -z "${SSH_AUTH_SOCK+x}" ]; then + dump "SSH_AUTH_SOCK isn't defined (ssh-agent not running?)" >&2 + return 1 + fi +} + add_ssh_key() { local password_path="$script_dir/password.txt" local password @@ -30,9 +47,10 @@ add_ssh_key() { DISPLAY="${DISPLAY-x}" SSH_ASKPASS="$askpass_path" ssh-add "$key_path" < /dev/null } -if [ -z "${SSH_AUTH_SOCK+x}" ]; then - echo "SSH_AUTH_SOCK isn't defined (ssh-agent not running?)" >&2 - exit 1 -fi -add_ssh_key -python3 -m pull.main "$@" +main() { + check_ssh_agent_running + add_ssh_key + python3 -m pull.main "$@" +} + +main "$@" |