Also, set -e doesn't cause failures when passing the output of a subshell
directly to eval, so use an intermediate variable instead.
-#!/bin/bash
+#!/bin/bash -e
# lifetime, in minutes
lifetime=15
function with-keys
{
unset SSH_AUTH_SOCK SSH_AGENT_PID
- eval $(keychain --timeout "$lifetime" --eval --host "$keychain_host" $keys)
+ vars=$(keychain --timeout "$lifetime" --eval --host "$keychain_host" $keys)
+ eval "$vars"
export SSHROOT=1
exec "$@"
}
function with-agent
{
unset SSH_AUTH_SOCK SSH_AGENT_PID
- eval $(keychain --timeout "$lifetime" --eval --host "$keychain_host")
+ vars=$(keychain --timeout "$lifetime" --eval --host "$keychain_host")
+ eval "$vars"
export SSHROOT=1
echo with-agent: Running: "$@"
exec "$@"