Skip to content

Commit

Permalink
fix regression created with #15. self verion had stopped working. now…
Browse files Browse the repository at this point in the history
… added a test for it
  • Loading branch information
kdabir committed Nov 17, 2018
1 parent ef55e62 commit 10c906e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 9 additions & 0 deletions .hastest.bats
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,12 @@ teardown() {
[[ "$(echo "${output}" | grep "" | grep "git")" ]]
[[ "$(echo "${output}" | grep "" | grep "bc")" ]]
}

@test "has prints help" {

run bash has

[[ "$(echo "${output}" | grep "has")" ]]
[[ "$(echo "${output}" | grep "USAGE:")" ]]
[[ "$(echo "${output}" | grep "EXAMPLE:")" ]]
}
9 changes: 5 additions & 4 deletions has
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ if [ -s "${RC_FILE}" ]; then
HASRC="true"
fi

# if no arguments passed to script
if [[ "${HASRC}" -ne "true" ]] && [ "$#" -eq 0 ]; then
# if HASRC is not set AND no arguments passed to script
if [[ -z "${HASRC}" ]] && [ "$#" -eq 0 ]; then
# print help
BINARY_NAME="has"
VERSION="v1.3.0"
Expand All @@ -188,9 +188,10 @@ else
## display found / total
# echo ${OK} / $(($OK+$KO))

if [[ "${HASRC}" == "true" ]]; then
## if HASRC has been set
if [[ -n "${HASRC}" ]]; then
## for all
for line in $(cat ".hasrc" | egrep -v "^\s*(#|$)" ); do
for line in $(cat "${RC_FILE}" | egrep -v "^\s*(#|$)" ); do
__detect "$line"
done
fi
Expand Down

0 comments on commit 10c906e

Please sign in to comment.