diff --git a/.hastest.bats b/.hastest.bats index 05adb9c..8992093 100644 --- a/.hastest.bats +++ b/.hastest.bats @@ -144,14 +144,16 @@ teardown() { } @test "testing archiving commands" { - run $has tar unzip gzip xz unar pv + run $has tar unzip gzip xz unar pv zip [ "$status" -eq 0 ] - [ "$(echo "${output}" | grep "tar")" ] - [ "$(echo "${output}" | grep "unzip")" ] - [ "$(echo "${output}" | grep "xz")" ] - [ "$(echo "${output}" | grep "unar")" ] - [ "$(echo "${output}" | grep "pv")" ] + [ "$(echo "${lines[0]}" | grep "tar")" ] + [ "$(echo "${lines[1]}" | grep "unzip")" ] + [ "$(echo "${lines[2]}" | grep "gzip")" ] + [ "$(echo "${lines[3]}" | grep "xz")" ] + [ "$(echo "${lines[4]}" | grep "unar")" ] + [ "$(echo "${lines[5]}" | grep "pv")" ] + [ "$(echo "${lines[6]}" | grep "zip")" ] } @test "testing coreutils commands" { @@ -162,3 +164,12 @@ teardown() { [ "$(echo "${lines[5]}" | grep "file")" ] [ "$(echo "${lines[6]}" | grep "gnu_coreutils")" ] } + +@test "testing hub version is different to git version" { + run $has hub git + + [ "$status" -eq 0 ] + [ "$(echo "${lines[0]}" | grep "hub")" ] + [ "$(echo "${lines[1]}" | grep "git")" ] + [ ! "${lines[0]##*\ }" = "${lines[1]##*\ }" ] +} diff --git a/has b/has index 0564077..185fa5d 100755 --- a/has +++ b/has @@ -154,6 +154,18 @@ __detect(){ # readlink (GNU coreutils) 8.28 gnu_coreutils) __dynamic_detect--version readlink ;; + ## hub uses --version but version string is on second line, or third if HUB_VERBOSE set + hub) + version=$(HUB_VERBOSE='' hub --version 2>&1 | sed -n 2p | grep -Eo "${REGEX_SIMPLE_VERSION}" | head -1) + status=$? + ;; + + ## zip uses -v but version string is on second line + zip) + version=$(zip -v 2>&1 | sed -n 2p | grep -Eo "${REGEX_SIMPLE_VERSION}" | head -1) + status=$? + ;; + has) version=$(has 2>&1 | grep -Eo "${REGEX_SIMPLE_VERSION}" | head -1) status=$?