dotfiles.sh: Replace `which` with `command -v`
authorW. Trevor King <wking@tremily.us>
Fri, 29 Mar 2013 17:19:58 +0000 (13:19 -0400)
committerW. Trevor King <wking@tremily.us>
Fri, 29 Mar 2013 17:22:35 +0000 (13:22 -0400)
I learned (via the Git list [1]) that `which` is not part of POSIX.
The POSIX 2008 equivalent is `command -v` [2].  We can make the shell
introduction more portable by sticking to the POSIX utilities [3],
especially since `command` is a Bash builtin.

[1]: http://article.gmane.org/gmane.comp.version-control.git/216007
[2]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/command.html
[3]: http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap04.html#tag_20

dotfiles.sh

index 5734dfb76283f775e849d2123adee215a85a8b6b..43309ba8ad05c07da6bcbcc1fd2d665db7bbe095 100755 (executable)
@@ -26,17 +26,17 @@ CHECK_WGET_TYPE_AND_ENCODING='no'
 #####
 # External utilities
 
-DIFF=${DOTFILES_DIFF:-$(which diff)}
-GIT=${DOTFILES_GIT:-$(which git)}
-LN=${DOTFILES_LN:-$(which ln)}
-MV=${DOTFILES_MV:-$(which mv)}
-PATCH=${DOTFILES_PATCH:-$(which patch)}
-SED=${DOTFILES_SED:-$(which sed)}
-RM=${DOTFILES_RM:-$(which rm)}
-RSYNC=${DOTFILES_RSYNC:-$(which rsync)}
-TAR=${DOTFILES_TAR:-$(which tar)}
-TOUCH=${DOTFILES_TOUCH:-$(which touch)}
-WGET=${DOTFILES_WGET:-$(which wget)}
+DIFF=${DOTFILES_DIFF:-$(command -v diff)}
+GIT=${DOTFILES_GIT:-$(command -v git)}
+LN=${DOTFILES_LN:-$(command -v ln)}
+MV=${DOTFILES_MV:-$(command -v mv)}
+PATCH=${DOTFILES_PATCH:-$(command -v patch)}
+SED=${DOTFILES_SED:-$(command -v sed)}
+RM=${DOTFILES_RM:-$(command -v rm)}
+RSYNC=${DOTFILES_RSYNC:-$(command -v rsync)}
+TAR=${DOTFILES_TAR:-$(command -v tar)}
+TOUCH=${DOTFILES_TOUCH:-$(command -v touch)}
+WGET=${DOTFILES_WGET:-$(command -v wget)}
 
 #####
 # Compatibility checks