From 860e20c62d20b50ab48a0f15b90721380c160f83 Mon Sep 17 00:00:00 2001 From: Michael Shigorin Date: Sat, 26 May 2012 13:10:41 +0300 Subject: [PATCH] lib/common.mk: avoid using uninitialized variables It somehow managed to evade me that $(TMP) might be uninitialized; definitely should be checked before stuffing into sed substitution command. NB: this could be done in pure make but my take was less readable. Thanks shadowsbrother/gmail for hitting and reporting this. --- lib/common.mk | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/common.mk b/lib/common.mk index df621164..16a1ff8e 100644 --- a/lib/common.mk +++ b/lib/common.mk @@ -7,10 +7,17 @@ BUILD_LOG = build.log SYMLINK = build # brevity postprocessor; not exported, for toplevel use only -SHORTEN = $(shell \ - echo -n "| sed"; \ +SHORTEN = $(shell FILTER=; \ if [ -s "$(SYMLINK)" ]; then \ - echo -n " -e 's,$(BUILDDIR),$(SYMLINK),'"; \ + FILTER=" -e 's,$(BUILDDIR),$(SYMLINK),'"; \ + fi; \ + if [ -n "$$TMP" ]; then \ + FILTER="$$FILTER -e 's,$$TMP,\$$TMP,'"; \ + fi; \ + if [ -n "$$HOME" ]; then \ + FILTER="$$FILTER -e 's,$$HOME,~,'"; \ + fi; \ + if [ -n "$$FILTER" ]; then \ + echo -n "| sed $$FILTER"; \ fi; \ - echo -n " -e 's,$(TMP),\$$TMP,' -e 's,$(HOME),~,'"; \ )