1 # $NetBSD: cond-short.mk,v 1.2 2020/06/28 11:06:26 rillig Exp $
3 # Demonstrates that in conditions, the right-hand side of an && or ||
4 # is only evaluated if it can actually influence the result.
6 # Between 2015-10-11 and 2020-06-28, the right-hand side of an && or ||
7 # operator was always evaluated, which was wrong.
12 .if 0 && ${echo "unexpected and" 1>&2 :L:sh}
15 .if 1 && ${echo "expected and" 1>&2 :L:sh}
18 .if 0 && exists(nonexistent${echo "unexpected and exists" 1>&2 :L:sh})
21 .if 1 && exists(nonexistent${echo "expected and exists" 1>&2 :L:sh})
24 .if 0 && empty(${echo "unexpected and empty" 1>&2 :L:sh})
27 .if 1 && empty(${echo "expected and empty" 1>&2 :L:sh})
32 .if 1 || ${echo "unexpected or" 1>&2 :L:sh}
35 .if 0 || ${echo "expected or" 1>&2 :L:sh}
38 .if 1 || exists(nonexistent${echo "unexpected or exists" 1>&2 :L:sh})
41 .if 0 || exists(nonexistent${echo "expected or exists" 1>&2 :L:sh})
44 .if 1 || empty(${echo "unexpected or empty" 1>&2 :L:sh})
47 .if 0 || empty(${echo "expected or empty" 1>&2 :L:sh})
50 # Unreachable nested conditions are skipped completely as well.
53 . if ${echo "unexpected nested and" 1>&2 :L:sh}
58 .elif ${echo "unexpected nested or" 1>&2 :L:sh}