aboutsummaryrefslogtreecommitdiff
path: root/contrib/bmake/unit-tests/sh-dots.mk
blob: f85af9025e55022edb7a9259e6b31a3cd42284b9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# $NetBSD: sh-dots.mk,v 1.3 2020/10/25 22:04:24 rillig Exp $
#
# Tests for the special shell command line "...", which does not run the
# commands below it but appends them to the list of commands that are run
# at the end.

.MAKEFLAGS: -d0			# switch stdout to being line-buffered

all: first hidden repeated commented indirect indirect-space

# The ${.TARGET} correctly expands to the target name, even though the
# commands are run separately from the main commands.
first:
	@echo first ${.TARGET}
	...
	@echo first delayed ${.TARGET}

# The dots cannot be prefixed by the usual @-+ characters.
# They must be written exactly as dots.
hidden: .IGNORE
	@echo hidden ${.TARGET}
	@...
	@echo hidden delayed ${.TARGET}

# Since the shell command lines don't recognize '#' as comment character,
# the "..." is not interpreted specially here.
commented: .IGNORE
	@echo commented ${.TARGET}
	...	# Run the below commands later
	@echo commented delayed ${.TARGET}

# The dots don't have to be written literally, they can also come from a
# variable expression.
indirect:
	@echo indirect regular
	${:U...}
	@echo indirect deferred

# If the dots are followed by a space, that space is part of the command and
# thus does not defer the command below it.
indirect-space: .IGNORE
	@echo indirect-space regular
	${:U... }
	@echo indirect-space deferred


# The "..." can appear more than once, even though that doesn't make sense.
# The second "..." is a no-op.
repeated: .IGNORE
	@echo repeated ${.TARGET}
	...
	@echo repeated delayed ${.TARGET}
	...
	@echo repeated delayed twice ${.TARGET}