aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Menzel <pmenzel@molgen.mpg.de>2017-01-30 15:56:41 +0100
committerPaul Menzel <pmenzel@molgen.mpg.de>2017-01-30 16:04:59 +0100
commit0755b55afbf76fcacc31e98bb8c163c8e055ccb2 (patch)
treebb220ccd6278cebb715f651809e82774282e787c
parent9a11988040da748397907dd46f17c7c8600c75d4 (diff)
downloadmcelog-0755b55afbf76fcacc31e98bb8c163c8e055ccb2.tar.gz
Makefile: Make `git` check portable (POSIX compatible)
On systems using not the *GNU Bourne-Again SHell* (bash) as shell, the git check might fail. This happens on Debian systems where the *Debian Almquist Shell* (dash) is used by default for `/bin/sh`. As a result, after running `make` the file `version.c` always contains `unknown` instead of the correct version. The problem is, that `type -p git` is not portable. Use `command -v` instead [1][2]. > Where bash is your shell/hashbang, consistently use hash (for > commands) or type (to consider built-ins & keywords). > > When writing a POSIX script, use command -v. Fixes: #42 [1] https://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-bash-script "Check if a program exists from a Bash script" [2] https://unix.stackexchange.com/questions/85249/why-not-use-which-what-to-use-then "Why not use “which”? What to use then?"
-rw-r--r--Makefile2
1 files changed, 1 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 9dbbdbf..e4341fc 100644
--- a/Makefile
+++ b/Makefile
@@ -82,7 +82,7 @@ depend: .depend
version.tmp: FORCE
( echo -n "char version[] = \"" ; \
- if type -p git >/dev/null; then \
+ if command -v git >/dev/null; then \
if [ -d .git ] ; then \
git describe --tags HEAD | tr -d '\n'; \
else \