summaryrefslogtreecommitdiff
path: root/unit-tests/varname-dot-curdir.mk
blob: e7af5c9528444b0f0b3116c120db125fabf10766 (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
# $NetBSD: varname-dot-curdir.mk,v 1.7 2020/10/08 19:09:08 rillig Exp $
#
# Tests for the special .CURDIR variable, which is initially set to the
# canonical path of the current working directory, when make started.

# In all normal situations, the current directory exists, and its name can
# be resolved.  If not, make fails at startup.
#
# It would be possible on some systems to remove the current directory, even
# while a process runs in it, but this is so unrealistic that it's no worth
# testing.
.if !exists(${.CURDIR})
.  error
.endif
.if !exists(${.CURDIR}/)
.  error
.endif
.if !exists(${.CURDIR}/.)
.  error
.endif
.if !exists(${.CURDIR}/..)
.  error
.endif

# Until 2020-10-04, assigning the result of a shell assignment to .CURDIR
# tried to add the shell command ("echo /") to the .PATH instead of the
# output of the shell command ("/").  Since "echo /" does not exist, the
# .PATH was left unmodified.  See VarAssign_Eval.
#
# Since 2020-10-04, the output of the shell command is added to .PATH.
.CURDIR!=	echo /
.if ${.PATH:M/} != "/"
.  error
.endif

# A normal assignment works fine, as does a substitution assignment.
# Appending to .CURDIR does not make sense, therefore it doesn't matter that
# this code path is buggy as well.
.CURDIR=	/
.if ${.PATH:M/} != "/"
.  error
.endif

all:
	@:;