From 9a0e055628f66dad6fe99916267c3006ed9ad464 Mon Sep 17 00:00:00 2001 From: Richard Soderberg Date: Thu, 3 Sep 2015 06:58:05 -0700 Subject: [PATCH] remove crude_grep in favor of a simple =~ substring match. The crude_grep function served only to perform a simple substring check against the output of openssl -help. So, instead of running the command each time, iterating its output line by line, and checking for the substring within it, this simply caches the -help output at startup and uses $help =~ substring to produce the same result in a single pass. --- cipherscan | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/cipherscan b/cipherscan index 16d2818..defbf60 100755 --- a/cipherscan +++ b/cipherscan @@ -19,6 +19,7 @@ if [[ "$(uname -s)" == "Darwin" ]]; then else OPENSSLBIN="${REALPATH}/openssl" fi +OPENSSLBINHELP="$($OPENSSLBIN s_client -help 2>&1)" # cipherscan requires bash4, which doesn't come by default in OSX if [[ ${BASH_VERSINFO[0]} -lt 4 ]]; then @@ -295,18 +296,8 @@ c_hash() { done } -crude_grep() { - while read line; do - if [[ $line =~ $1 ]]; then - return 0 - fi - done - return 1 -} - check_option_support() { - $OPENSSLBIN s_client -help 2>&1 | crude_grep "$1" - return $? + [[ $OPENSSLBINHELP =~ "$1" ]] } parse_openssl_output() {