diff options
author | Jean-Sébastien Pédron <[email protected]> | 2015-06-19 12:08:28 +0200 |
---|---|---|
committer | Jean-Sébastien Pédron <[email protected]> | 2015-06-19 12:08:28 +0200 |
commit | 0040f93ccd5f4aa6db719741fcd6335c48d1390d (patch) | |
tree | 97a34e84b8428d5b1ee74535fa1269b45e4ec631 /core/deps.mk | |
parent | 1b9e73c99561e0661862b10f3c5fd9dbb8cc1f0f (diff) | |
download | erlang.mk-0040f93ccd5f4aa6db719741fcd6335c48d1390d.tar.gz erlang.mk-0040f93ccd5f4aa6db719741fcd6335c48d1390d.tar.bz2 erlang.mk-0040f93ccd5f4aa6db719741fcd6335c48d1390d.zip |
dep_autopatch: Ensure ['s `!=` operator has operands
Consider the following test:
elif [ 0 != `find ... | xargs grep -ci rebar` ]; then
find(1) may return no file at all and xargs has nothing on its stdin. In
this case, GNU xargs (from findutils) still executes the given command
and grep(1) returns 0.
However, FreeBSD's xargs for instance does not run the command at all if
there is nothing on stdin. Therefore nothing is printed on stdout and the
test becomes:
elif [ 0 != ]; then
This triggers a warning from the shell:
[: !=: argument expected
Prepending both operands with a literal 'x' fixes the problem.
For consistency's sake, I modified the two other tests as well, though
I didn't have any problem with them.
Diffstat (limited to 'core/deps.mk')
-rw-r--r-- | core/deps.mk | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/core/deps.mk b/core/deps.mk index 78ce3ca..8a104f4 100644 --- a/core/deps.mk +++ b/core/deps.mk @@ -67,11 +67,11 @@ distclean:: distclean-deps distclean-pkg # in practice only Makefile is needed so far. define dep_autopatch if [ -f $(DEPS_DIR)/$(1)/Makefile ]; then \ - if [ 0 != `grep -c "include ../\w*\.mk" $(DEPS_DIR)/$(1)/Makefile` ]; then \ + if [ x0 != x`grep -c "include ../\w*\.mk" $(DEPS_DIR)/$(1)/Makefile` ]; then \ $(call dep_autopatch2,$(1)); \ - elif [ 0 != `grep -ci rebar $(DEPS_DIR)/$(1)/Makefile` ]; then \ + elif [ x0 != x`grep -ci rebar $(DEPS_DIR)/$(1)/Makefile` ]; then \ $(call dep_autopatch2,$(1)); \ - elif [ 0 != `find $(DEPS_DIR)/$(1)/ -type f -name \*.mk -not -name erlang.mk | xargs grep -ci rebar` ]; then \ + elif [ x0 != x`find $(DEPS_DIR)/$(1)/ -type f -name \*.mk -not -name erlang.mk | xargs grep -ci rebar` ]; then \ $(call dep_autopatch2,$(1)); \ else \ if [ -f $(DEPS_DIR)/$(1)/erlang.mk ]; then \ |