From 8b9c2d458ad86e632febcf26f71a9cb0bf5750f8 Mon Sep 17 00:00:00 2001 From: Alex Dehnert Date: Sat, 15 Dec 2012 08:20:57 -0500 Subject: [PATCH] sshroot: use set -e Also, set -e doesn't cause failures when passing the output of a subshell directly to eval, so use an intermediate variable instead. --- sshroot | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sshroot b/sshroot index 845a04a..740b5ef 100755 --- a/sshroot +++ b/sshroot @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -e # lifetime, in minutes lifetime=15 @@ -38,7 +38,8 @@ keychain_host="$hostopt-$keysuffix" 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 "$@" } @@ -46,7 +47,8 @@ function with-keys 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 "$@" -- 2.34.1