Changes of interest o unit-tests: use private TMPDIR to avoid errors from other users o avoid strdup in mkTempFile o always use vfork o job.c: do not create empty shell files in jobs mode reduce unnecessary calls to waitpid o cond.c: fix debug output for comparison operators in conditionals
35 lines
1.0 KiB
Makefile
35 lines
1.0 KiB
Makefile
# $NetBSD: cmdline-redirect-stdin.mk,v 1.1 2021/02/01 20:31:41 rillig Exp $
|
|
#
|
|
# Demonstrate that the '!=' assignment operator can read individual lines
|
|
# from make's stdin.
|
|
#
|
|
# This edge case is an implementation detail that has no practical
|
|
# application.
|
|
|
|
all: .PHONY
|
|
@printf '%s\n' "first line" "second line" \
|
|
| ${MAKE} -f ${MAKEFILE} read-lines
|
|
|
|
.if make(read-lines)
|
|
line1!= read line; echo "$$line"
|
|
line2!= read line; echo "$$line"
|
|
|
|
.if ${line1} != "first line"
|
|
. error line1="${line1}"
|
|
|
|
.elif ${line2} == ""
|
|
# If this branch is ever reached, the shell from the assignment to line1
|
|
# probably buffers its input. Most shells use unbuffered stdin, and this
|
|
# is actually specified by POSIX, which says that "The read utility shall
|
|
# read a single line from standard input". This is the reason why the shell
|
|
# reads its input byte by byte, which makes it terribly slow for practical
|
|
# applications.
|
|
. error The shell's read command does not read a single line.
|
|
|
|
.elif ${line2} != "second line"
|
|
. error line2="${line2}"
|
|
.endif
|
|
|
|
read-lines: .PHONY
|
|
.endif
|