Skip to content

Commit

Permalink
Fixes broken which behavior in zsh
Browse files Browse the repository at this point in the history
  • Loading branch information
paoloantinori committed Feb 9, 2016
1 parent af2b9e7 commit 858c1d1
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions h.sh
Expand Up @@ -21,10 +21,7 @@
# * https://github.com/paoloantinori/hhighlighter

# Check for the ack command
if [[ -z $(type -p ack-grep || type -p ack) ]]; then
echo "ERROR: Could not find the ack or ack-grep commands"
return 1
fi



h() {
Expand Down Expand Up @@ -119,7 +116,22 @@ Check the content of your H_COLORS_FG and H_COLORS_BG environment variables or u
return 1
fi

local ACK=$(type -p ack-grep || type -p ack)
if [ -n "$ZSH_VERSION" ]; then
local WHICH="whence"
else [ -n "$BASH_VERSION" ]
local WHICH="type -P"
fi

if ! ACKGREP_LOC="$($WHICH ack-grep)" || [ -z "$ACKGREP_LOC" ]; then
if ! ACK_LOC="$($WHICH ack)" || [ -z "$ACK_LOC" ]; then
echo "ERROR: Could not find the ack or ack-grep commands"
return 1
else
local ACK=$($WHICH ack)
fi
else
local ACK=$($WHICH ack-grep)
fi

# build the filtering command
for keyword in "$@"
Expand Down

0 comments on commit 858c1d1

Please sign in to comment.