Skip to content

Commit

Permalink
bugfixes and more tools (#61)
Browse files Browse the repository at this point in the history
- `cmake`
- `openssh`/`ssh`

- `openssl` now includes letters at the end (eg. "1.1.1j")
- `has` didn't actually detect its own version
  • Loading branch information
reyemxela authored Jul 28, 2023
1 parent 49444b3 commit c12a38b
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions has
Original file line number Diff line number Diff line change
Expand Up @@ -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" ;;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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 ;;
Expand All @@ -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=$?
;;

Expand Down

0 comments on commit c12a38b

Please sign in to comment.