1*6a7405f5SSimon J. Gerraty# $NetBSD: cond-op-not.mk,v 1.9 2024/08/06 18:00:17 rillig Exp $ 22c3632d1SSimon J. Gerraty# 3e2eeea75SSimon J. Gerraty# Tests for the ! operator in .if conditions, which negates its argument. 42c3632d1SSimon J. Gerraty 52c3632d1SSimon J. Gerraty# The exclamation mark negates its operand. 62c3632d1SSimon J. Gerraty.if !1 72c3632d1SSimon J. Gerraty. error 82c3632d1SSimon J. Gerraty.endif 92c3632d1SSimon J. Gerraty 102c3632d1SSimon J. Gerraty# Exclamation marks can be chained. 112c3632d1SSimon J. Gerraty# This doesn't happen in practice though. 122c3632d1SSimon J. Gerraty.if !!!1 132c3632d1SSimon J. Gerraty. error 142c3632d1SSimon J. Gerraty.endif 152c3632d1SSimon J. Gerraty 162c3632d1SSimon J. Gerraty# The ! binds more tightly than the &&. 172c3632d1SSimon J. Gerraty.if !!0 && 1 182c3632d1SSimon J. Gerraty. error 192c3632d1SSimon J. Gerraty.endif 202c3632d1SSimon J. Gerraty 21e2eeea75SSimon J. Gerraty# The operator '==' binds more tightly than '!'. 22e2eeea75SSimon J. Gerraty# This is unusual since most other programming languages define the precedence 23e2eeea75SSimon J. Gerraty# to be the other way round. 24e2eeea75SSimon J. Gerraty.if !${:Uexpression} == "expression" 25e2eeea75SSimon J. Gerraty. error 26e2eeea75SSimon J. Gerraty.endif 27e2eeea75SSimon J. Gerraty 28e2eeea75SSimon J. Gerraty.if !${:U} 29148ee845SSimon J. Gerraty# expect+1: Not empty evaluates to true. 30e2eeea75SSimon J. Gerraty. info Not empty evaluates to true. 31e2eeea75SSimon J. Gerraty.else 32e2eeea75SSimon J. Gerraty. info Not empty evaluates to false. 33e2eeea75SSimon J. Gerraty.endif 34e2eeea75SSimon J. Gerraty 35e2eeea75SSimon J. Gerraty.if !${:U } 36e2eeea75SSimon J. Gerraty. info Not space evaluates to true. 37e2eeea75SSimon J. Gerraty.else 38148ee845SSimon J. Gerraty# expect+1: Not space evaluates to false. 39e2eeea75SSimon J. Gerraty. info Not space evaluates to false. 40e2eeea75SSimon J. Gerraty.endif 41e2eeea75SSimon J. Gerraty 42e2eeea75SSimon J. Gerraty.if !${:U0} 43148ee845SSimon J. Gerraty# expect+1: Not 0 evaluates to true. 44e2eeea75SSimon J. Gerraty. info Not 0 evaluates to true. 45e2eeea75SSimon J. Gerraty.else 46e2eeea75SSimon J. Gerraty. info Not 0 evaluates to false. 47e2eeea75SSimon J. Gerraty.endif 48e2eeea75SSimon J. Gerraty 49e2eeea75SSimon J. Gerraty.if !${:U1} 50e2eeea75SSimon J. Gerraty. info Not 1 evaluates to true. 51e2eeea75SSimon J. Gerraty.else 52148ee845SSimon J. Gerraty# expect+1: Not 1 evaluates to false. 53e2eeea75SSimon J. Gerraty. info Not 1 evaluates to false. 54e2eeea75SSimon J. Gerraty.endif 55e2eeea75SSimon J. Gerraty 56e2eeea75SSimon J. Gerraty.if !${:Uword} 57e2eeea75SSimon J. Gerraty. info Not word evaluates to true. 58e2eeea75SSimon J. Gerraty.else 59148ee845SSimon J. Gerraty# expect+1: Not word evaluates to false. 60e2eeea75SSimon J. Gerraty. info Not word evaluates to false. 61e2eeea75SSimon J. Gerraty.endif 62e2eeea75SSimon J. Gerraty 63dba7b0efSSimon J. Gerraty# A single exclamation mark is a parse error. 64*6a7405f5SSimon J. Gerraty# expect+1: Malformed conditional '!' 65dba7b0efSSimon J. Gerraty.if ! 66dba7b0efSSimon J. Gerraty. error 67dba7b0efSSimon J. Gerraty.else 68dba7b0efSSimon J. Gerraty. error 69dba7b0efSSimon J. Gerraty.endif 70dba7b0efSSimon J. Gerraty 712c3632d1SSimon J. Gerratyall: 722c3632d1SSimon J. Gerraty @:; 73