summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortv <tv@nomic.retiolum>2013-02-08 21:09:25 +0100
committertv <tv@nomic.retiolum>2013-02-08 21:09:50 +0100
commitc5953301c721096e97ce7e83037f0da85ee4eaa7 (patch)
tree83dea56dfc10439908424304b7affa21baa695d1
parenta351123fe617f3d273cd2c1c148c861816046576 (diff)
//services/bin/services: propagate ssh's exit code
-rwxr-xr-xservices/bin/services17
1 files changed, 12 insertions, 5 deletions
diff --git a/services/bin/services b/services/bin/services
index e854cbcb..31aca200 100755
--- a/services/bin/services
+++ b/services/bin/services
@@ -25,9 +25,16 @@ fi
exec 3>&1
{
+ set +e
ssh $options $user@$hostname -p $port
-} 2>&1 1>&3 | sed '
- /^Connection to '$hostname' closed/d
- /^Shared connection to '$hostname' closed/d
-'
-exec 3>&-
+ echo "# Exit:$?" >&2
+} 2>&1 1>&3 | {
+ err="`cat`"
+ code=`echo "$err" | sed -n 's/^# Exit:\([0-9]\+\)/\1/p'`
+ echo "$err" | sed '
+ /^Connection to '$hostname' closed/d
+ /^Shared connection to '$hostname' closed/d
+ /^# Exit:/d
+ ' >&2
+ exit $code
+}