From a41507b7b42f258a7be5afd33e40187b2351a863 Mon Sep 17 00:00:00 2001 From: dtucker Date: Mon, 25 Mar 2024 02:07:08 +0000 Subject: [PATCH] Save error code from SSH for use inside case statement, from portable. In some shells, "case" will reset the value of $?, so save it first. --- regress/usr.bin/ssh/key-options.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/regress/usr.bin/ssh/key-options.sh b/regress/usr.bin/ssh/key-options.sh index b15b81191d1..93d9af47815 100644 --- a/regress/usr.bin/ssh/key-options.sh +++ b/regress/usr.bin/ssh/key-options.sh @@ -1,4 +1,4 @@ -# $OpenBSD: key-options.sh,v 1.9 2018/07/03 13:53:26 djm Exp $ +# $OpenBSD: key-options.sh,v 1.10 2024/03/25 02:07:08 dtucker Exp $ # Placed in the Public Domain. tid="key options" @@ -102,9 +102,10 @@ check_valid_before() { sed "s/.*/$opts &/" $origkeys >$authkeys verbose "key option expiry-time $which" ${SSH} -q -F $OBJ/ssh_proxy somehost true + r=$? case "$expect" in - fail) test $? -eq 0 && fail "key option succeeded $which" ;; - pass) test $? -ne 0 && fail "key option failed $which" ;; + fail) test $r -eq 0 && fail "key option succeeded $which" ;; + pass) test $r -ne 0 && fail "key option failed $which" ;; *) fatal "unknown expectation $expect" ;; esac } -- 2.20.1