aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xafssh19
1 files changed, 16 insertions, 3 deletions
diff --git a/afssh b/afssh
index 364187b..97a0a25 100755
--- a/afssh
+++ b/afssh
@@ -23,7 +23,7 @@ set -e
declare -a agent_filter_args
while true; do
- if [[ $1 = "--" ]]; then
+ if [ "$1" = "--" ]; then
shift
break
else
@@ -32,7 +32,20 @@ while true; do
fi
done
-eval $(${BASH_SOURCE%/*}/ssh-agent-filter "${agent_filter_args[@]}" || echo exit $?)
-trap 'kill "$SSH_AGENT_PID"' EXIT
+# safeguard to not kill the real ssh-agent
+unset SSH_AGENT_PID
+
+trap 'kill "$SSH_AGENT_PID"; rm -r "$TEMPDIR"' EXIT
+TEMPDIR=$(mktemp -d)
+
+if [ -x "${BASH_SOURCE%/*}/ssh-agent-filter" ]; then
+ SAF=$(readlink -f "${BASH_SOURCE%/*}/ssh-agent-filter")
+else
+ SAF=$(which ssh-agent-filter)
+fi
+
+eval $(cd "$TEMPDIR"; "$SAF" "${agent_filter_args[@]}" || echo exit $?)
+
+ssh-add -l
ssh -A "$@"