Skip to content

Commit 4769948

Browse files
author
Junio C Hamano
committed
Deal with $(bindir) and friends with whitespaces.
... using HPA's shellquote macro. Signed-off-by: Junio C Hamano <junkio@cox.net>
1 parent d5b0c9e commit 4769948

File tree

4 files changed

+36
-18
lines changed

4 files changed

+36
-18
lines changed

Makefile

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,12 @@ LIB_OBJS = \
163163
LIBS = $(LIB_FILE)
164164
LIBS += -lz
165165

166+
# Shell quote;
167+
# Result of this needs to be placed inside ''
168+
shq = $(subst ','\'',$(1))
169+
# This has surrounding ''
170+
shellquote = '$(call shq,$(1))'
171+
166172
#
167173
# Platform specific tweaks
168174
#
@@ -235,7 +241,7 @@ ifndef NO_OPENSSL
235241
OPENSSL_LINK =
236242
endif
237243
else
238-
DEFINES += '-DNO_OPENSSL'
244+
DEFINES += -DNO_OPENSSL
239245
MOZILLA_SHA1 = 1
240246
OPENSSL_LIBSSL =
241247
endif
@@ -294,7 +300,7 @@ endif
294300
endif
295301
endif
296302

297-
DEFINES += '-DSHA1_HEADER=$(SHA1_HEADER)'
303+
DEFINES += -DSHA1_HEADER=$(call shellquote,$(SHA1_HEADER))
298304

299305
SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
300306
$(patsubst %.perl,%,$(SCRIPT_PERL)) \
@@ -311,7 +317,7 @@ all:
311317

312318
git: git.sh Makefile
313319
rm -f $@+ $@
314-
sed -e '1s|#!.*/sh|#!$(SHELL_PATH)|' \
320+
sed -e '1s|#!.*/sh|#!$(call shq,$(SHELL_PATH))|' \
315321
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
316322
-e 's/@@X@@/$(X)/g' \
317323
$(GIT_LIST_TWEAK) <$@.sh >$@+
@@ -320,22 +326,22 @@ git: git.sh Makefile
320326

321327
$(filter-out git,$(patsubst %.sh,%,$(SCRIPT_SH))) : % : %.sh
322328
rm -f $@
323-
sed -e '1s|#!.*/sh|#!$(SHELL_PATH)|' \
329+
sed -e '1s|#!.*/sh|#!$(call shq,$(SHELL_PATH))|' \
324330
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
325331
$@.sh >$@
326332
chmod +x $@
327333

328334
$(patsubst %.perl,%,$(SCRIPT_PERL)) : % : %.perl
329335
rm -f $@
330-
sed -e '1s|#!.*perl|#!$(PERL_PATH)|' \
336+
sed -e '1s|#!.*perl|#!$(call shq,$(PERL_PATH))|' \
331337
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
332338
$@.perl >$@
333339
chmod +x $@
334340

335341
$(patsubst %.py,%,$(SCRIPT_PYTHON)) : % : %.py
336342
rm -f $@
337-
sed -e '1s|#!.*python|#!$(PYTHON_PATH)|' \
338-
-e 's|@@GIT_PYTHON_PATH@@|$(GIT_PYTHON_DIR)|g' \
343+
sed -e '1s|#!.*python|#!$(call shq,$(PYTHON_PATH))|' \
344+
-e 's|@@GIT_PYTHON_PATH@@|$(call shq,$(GIT_PYTHON_DIR))|g' \
339345
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
340346
$@.py >$@
341347
chmod +x $@
@@ -365,7 +371,7 @@ git-rev-list$X: LIBS += $(OPENSSL_LIBSSL)
365371

366372
init-db.o: init-db.c
367373
$(CC) -c $(ALL_CFLAGS) \
368-
-DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir)"' $*.c
374+
-DDEFAULT_GIT_TEMPLATE_DIR=$(call shellquote,"$(template_dir)") $*.c
369375

370376
$(LIB_OBJS): $(LIB_H)
371377
$(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H)
@@ -397,13 +403,13 @@ check:
397403
### Installation rules
398404

399405
install: $(PROGRAMS) $(SCRIPTS)
400-
$(INSTALL) -d -m755 $(DESTDIR)$(bindir)
401-
$(INSTALL) $(PROGRAMS) $(SCRIPTS) $(DESTDIR)$(bindir)
402-
$(INSTALL) git-revert $(DESTDIR)$(bindir)/git-cherry-pick
403-
sh ./cmd-rename.sh $(DESTDIR)$(bindir)
406+
$(INSTALL) -d -m755 $(call shellquote,$(DESTDIR)$(bindir))
407+
$(INSTALL) $(PROGRAMS) $(SCRIPTS) $(call shellquote,$(DESTDIR)$(bindir))
408+
$(INSTALL) git-revert $(call shellquote,$(DESTDIR)$(bindir)/git-cherry-pick)
409+
sh ./cmd-rename.sh $(call shellquote,$(DESTDIR)$(bindir))
404410
$(MAKE) -C templates install
405-
$(INSTALL) -d -m755 $(DESTDIR)$(GIT_PYTHON_DIR)
406-
$(INSTALL) $(PYMODULES) $(DESTDIR)$(GIT_PYTHON_DIR)
411+
$(INSTALL) -d -m755 $(call shellquote,$(DESTDIR)$(GIT_PYTHON_DIR))
412+
$(INSTALL) $(PYMODULES) $(call shellquote,$(DESTDIR)$(GIT_PYTHON_DIR))
407413

408414
install-doc:
409415
$(MAKE) -C Documentation install

git-merge-recursive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from heapq import heappush, heappop
55
from sets import Set
66

7-
sys.path.append('@@GIT_PYTHON_PATH@@')
7+
sys.path.append('''@@GIT_PYTHON_PATH@@''')
88
from gitMergeCommon import *
99

1010
originalIndexFile = os.environ.get('GIT_INDEX_FILE',

t/Makefile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,16 @@
77
SHELL_PATH ?= $(SHELL)
88
TAR ?= $(TAR)
99

10+
# Shell quote;
11+
# Result of this needs to be placed inside ''
12+
shq = $(subst ','\'',$(1))
13+
# This has surrounding ''
14+
shellquote = '$(call shq,$(1))'
15+
1016
T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
1117

1218
all:
13-
@$(foreach t,$T,echo "*** $t ***"; $(SHELL_PATH) $t $(GIT_TEST_OPTS) || exit; )
19+
@$(foreach t,$T,echo "*** $t ***"; $(call shellquote,$(SHELL_PATH)) $t $(GIT_TEST_OPTS) || exit; )
1420
@rm -fr trash
1521

1622
clean:

templates/Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ prefix ?= $(HOME)
66
template_dir ?= $(prefix)/share/git-core/templates/
77
# DESTDIR=
88

9+
# Shell quote;
10+
# Result of this needs to be placed inside ''
11+
shq = $(subst ','\'',$(1))
12+
# This has surrounding ''
13+
shellquote = '$(call shq,$(1))'
14+
915
all: boilerplates.made custom
1016
find blt
1117

@@ -38,6 +44,6 @@ clean:
3844
rm -rf blt boilerplates.made
3945

4046
install: all
41-
$(INSTALL) -d -m755 $(DESTDIR)$(template_dir)
47+
$(INSTALL) -d -m755 $(call shellquote,$(DESTDIR)$(template_dir))
4248
(cd blt && $(TAR) cf - .) | \
43-
(cd $(DESTDIR)$(template_dir) && $(TAR) xf -)
49+
(cd $(call shellquote,$(DESTDIR)$(template_dir)) && $(TAR) xf -)

0 commit comments

Comments
 (0)