4 usage
="Usage: $0 [-bc] [COMMAND [ARGS...]]"
7 case "${SHELL-/bin/sh}" in
11 force
= chosen
= commands
=
12 while [ $# -gt
0 ]; do
14 -h |
--help) echo "$usage"; exit 0;;
15 -c |
--cshell |
--tcsh
) style
=csh chosen
=t
;;
16 -b |
--bourne |
--bash |
--zsh
) style
=sh chosen
=t
;;
17 -f |
--force
) force
=t
;;
19 -*) echo >&2 "$usage"; exit 1;;
24 [ $# -gt
0 ] && style
=commands
25 case $chosen,$style in
27 echo >&2 "$0: output style and commands? you're odd"
32 ### Should I start a new agent?
33 case "$force,$SSH_AUTH_SOCK" in
39 set +e
; ssh-add
-l
>/dev
/null
2>&1; rc
=$?
; set -e
40 [ $rc -ge
2 ] && start
=t
46 hostname
=${HOST-$(hostname)}
47 user
=${USER-${LOGNAME-$(whoami)}}
48 dir
=$TMPDIR/.ssh-agent.
$hostname.
$user; socket
=$dir/sock
; pid
=$dir/pid
50 SSH_AUTH_SOCK
=$socket; export SSH_AUTH_SOCK
51 set +e
; ssh-add
-l
>/dev
/null
2>&1; rc
=$?
; set -e
52 if [ $rc -ge
2 ]; then
53 if [ -f
"$pid" ]; then
54 kill $
(cat "$pid") >/dev
/null
2>&1 ||
:
56 rm -f
"$socket" "$pid"
57 (cd /; exec ssh-agent
-d
-a
"$socket" >/dev
/null
2>&1)&
59 SSH_AUTH_SOCK
=$socket; export SSH_AUTH_SOCK
63 ### Run a program, or export the details
66 echo "SSH_AUTH_SOCK='$SSH_AUTH_SOCK'; export SSH_AUTH_SOCK"
69 echo "setenv SSH_AUTH_SOCK '$SSH_AUTH_SOCK'"