xref: /freebsd/contrib/bmake/unit-tests/varname-dot-curdir.mk (revision 956e45f6fb3e18b8e89b1341708db60c30bb9f27)
1*956e45f6SSimon J. Gerraty# $NetBSD: varname-dot-curdir.mk,v 1.7 2020/10/08 19:09:08 rillig Exp $
22c3632d1SSimon J. Gerraty#
3*956e45f6SSimon J. Gerraty# Tests for the special .CURDIR variable, which is initially set to the
4*956e45f6SSimon J. Gerraty# canonical path of the current working directory, when make started.
52c3632d1SSimon J. Gerraty
6*956e45f6SSimon J. Gerraty# In all normal situations, the current directory exists, and its name can
7*956e45f6SSimon J. Gerraty# be resolved.  If not, make fails at startup.
8*956e45f6SSimon J. Gerraty#
9*956e45f6SSimon J. Gerraty# It would be possible on some systems to remove the current directory, even
10*956e45f6SSimon J. Gerraty# while a process runs in it, but this is so unrealistic that it's no worth
11*956e45f6SSimon J. Gerraty# testing.
12*956e45f6SSimon J. Gerraty.if !exists(${.CURDIR})
13*956e45f6SSimon J. Gerraty.  error
14*956e45f6SSimon J. Gerraty.endif
15*956e45f6SSimon J. Gerraty.if !exists(${.CURDIR}/)
16*956e45f6SSimon J. Gerraty.  error
17*956e45f6SSimon J. Gerraty.endif
18*956e45f6SSimon J. Gerraty.if !exists(${.CURDIR}/.)
19*956e45f6SSimon J. Gerraty.  error
20*956e45f6SSimon J. Gerraty.endif
21*956e45f6SSimon J. Gerraty.if !exists(${.CURDIR}/..)
22*956e45f6SSimon J. Gerraty.  error
23*956e45f6SSimon J. Gerraty.endif
24*956e45f6SSimon J. Gerraty
25*956e45f6SSimon J. Gerraty# Until 2020-10-04, assigning the result of a shell assignment to .CURDIR
26*956e45f6SSimon J. Gerraty# tried to add the shell command ("echo /") to the .PATH instead of the
27*956e45f6SSimon J. Gerraty# output of the shell command ("/").  Since "echo /" does not exist, the
28*956e45f6SSimon J. Gerraty# .PATH was left unmodified.  See VarAssign_Eval.
29*956e45f6SSimon J. Gerraty#
30*956e45f6SSimon J. Gerraty# Since 2020-10-04, the output of the shell command is added to .PATH.
31*956e45f6SSimon J. Gerraty.CURDIR!=	echo /
32*956e45f6SSimon J. Gerraty.if ${.PATH:M/} != "/"
33*956e45f6SSimon J. Gerraty.  error
34*956e45f6SSimon J. Gerraty.endif
35*956e45f6SSimon J. Gerraty
36*956e45f6SSimon J. Gerraty# A normal assignment works fine, as does a substitution assignment.
37*956e45f6SSimon J. Gerraty# Appending to .CURDIR does not make sense, therefore it doesn't matter that
38*956e45f6SSimon J. Gerraty# this code path is buggy as well.
39*956e45f6SSimon J. Gerraty.CURDIR=	/
40*956e45f6SSimon J. Gerraty.if ${.PATH:M/} != "/"
41*956e45f6SSimon J. Gerraty.  error
42*956e45f6SSimon J. Gerraty.endif
432c3632d1SSimon J. Gerraty
442c3632d1SSimon J. Gerratyall:
452c3632d1SSimon J. Gerraty	@:;
46