f46d06dae19f691e6666d4836766e9eb69d2e51b

Author
Henrik Holm <henrik@henrikholm.com>
Committer
Henrik Holm <henrik@henrikholm.com>
Date

Message

Correct redirection of output from 'hash'

The intention of the redirection to /dev/null is to hide the output
'hash: no such command: git' since we rely on the exit status.

However, the output goes to stderr, so it's stderr that needs to be
redirected. For completeness, we redirect both stderr and stdout using
'2>&1'.

Example:

  [~]$ hash git > /dev/null
  [~]$ PATH=''
  [~]$ hash git > /dev/null
  hash: no such command: git
  [~]$ hash git > /dev/null 2>&1
  [~]$

Diff

 1diff --git a/tools/install.sh b/tools/install.sh
 2index 71e19a389f7899a8883c5835d1ceb0655c845e22..fc7ad70cf0b4521889d30d7622e6dd1bf8f314ef 100755
 3--- a/tools/install.sh
 4+++ b/tools/install.sh
 5@@ -10,7 +10,7 @@ if [ -d "$ZSH" ]; then
 6 fi
 7 
 8 echo "\033[0;34mCloning Oh My Zsh...\033[0m"
 9-hash git >/dev/null && /usr/bin/env git clone https://github.com/robbyrussell/oh-my-zsh.git $ZSH || {
10+hash git >/dev/null 2>&1 && /usr/bin/env git clone https://github.com/robbyrussell/oh-my-zsh.git $ZSH || {
11   echo "git not installed"
12   exit
13 }