From c12a38bbddab066b98abdb614b613a7f05874b3e Mon Sep 17 00:00:00 2001 From: Alex Meyer Date: Fri, 28 Jul 2023 09:35:54 -0400 Subject: [PATCH] bugfixes and more tools (#61) - `cmake` - `openssh`/`ssh` - `openssl` now includes letters at the end (eg. "1.1.1j") - `has` didn't actually detect its own version --- has | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/has b/has index d93a2ad..0c03b78 100755 --- a/has +++ b/has @@ -103,6 +103,7 @@ __detect(){ case ${name} in rust ) command="rustc" ;; ssl ) command="openssl" ;; + openssh ) command="ssh" ;; golang ) command="go" ;; jre ) command="java" ;; jdk ) command="javac" ;; @@ -166,7 +167,7 @@ __detect(){ groovy|node) __dynamic_detect--version "${command}" ;; ## Compile - gcc|make|bats) __dynamic_detect--version "${command}" ;; + gcc|make|cmake|bats) __dynamic_detect--version "${command}" ;; ninja) __dynamic_detect--version "${command}" ;; ## Build tools @@ -208,7 +209,6 @@ __detect(){ # commands that need version arg go|hugo) __dynamic_detect-arg_version "${command}" ;; - openssl) __dynamic_detect-arg_version "${command}" ;; ## Example of commands that need custom processing @@ -228,6 +228,18 @@ __detect(){ status=$? ;; + # openssl can have a letter at the end of the version number (eg. "1.1.1j") + openssl) + version=$( openssl version 2>&1 | grep -Eo "${REGEX_SIMPLE_VERSION}[[:alnum:]]*" |head -1) + status=$? + ;; + + # openssh version output has a lot going on + ssh) + version=$(ssh -V 2>&1 |grep -Eo "OpenSSH_${REGEX_SIMPLE_VERSION}[[:alnum:]]*" |cut -d'_' -f2) + status=$? + ;; + ## use 'readlink' to test for GNU coreutils # readlink (GNU coreutils) 8.28 gnu_coreutils) __dynamic_detect--version readlink ;; @@ -245,7 +257,7 @@ __detect(){ ;; has) - version=$( has 2>&1 | grep -Eo "${REGEX_SIMPLE_VERSION}" | head -1) + version=$( has -V 2>&1 | grep -Eo "${REGEX_SIMPLE_VERSION}" | head -1) status=$? ;;