xref: /freebsd/contrib/bmake/unit-tests/sh-errctl.mk (revision 06b9b3e0ad0dc3f0166b3e8f26ced68c271cf527)
1*06b9b3e0SSimon J. Gerraty# $NetBSD: sh-errctl.mk,v 1.1 2020/12/12 15:06:11 rillig Exp $
2*06b9b3e0SSimon J. Gerraty#
3*06b9b3e0SSimon J. Gerraty# Test a shell with error control.  This only works in jobs mode; in compat
4*06b9b3e0SSimon J. Gerraty# mode, the default shell is always used, see InitShellNameAndPath.
5*06b9b3e0SSimon J. Gerraty#
6*06b9b3e0SSimon J. Gerraty# There is a subtle difference between error control and echo control.
7*06b9b3e0SSimon J. Gerraty# With error control, each simple command is checked, whereas with echo
8*06b9b3e0SSimon J. Gerraty# control, only the last command from each line is checked.  A shell command
9*06b9b3e0SSimon J. Gerraty# line that behaves differently in these two modes is "false; true".  In
10*06b9b3e0SSimon J. Gerraty# error control mode, this fails, while in echo control mode, it succeeds.
11*06b9b3e0SSimon J. Gerraty
12*06b9b3e0SSimon J. Gerraty.MAKEFLAGS: -j1 -dj
13*06b9b3e0SSimon J. Gerraty
14*06b9b3e0SSimon J. Gerraty.SHELL: \
15*06b9b3e0SSimon J. Gerraty	name="sh" \
16*06b9b3e0SSimon J. Gerraty	path="${.SHELL}" \
17*06b9b3e0SSimon J. Gerraty	hasErrCtl="yes" \
18*06b9b3e0SSimon J. Gerraty	check="\# error checking on\nset -e" \
19*06b9b3e0SSimon J. Gerraty	ignore="\# error checking off\nset +e" \
20*06b9b3e0SSimon J. Gerraty	echo="\# echo on" \
21*06b9b3e0SSimon J. Gerraty	quiet="\# echo off"
22*06b9b3e0SSimon J. Gerraty
23*06b9b3e0SSimon J. Gerratyall:
24*06b9b3e0SSimon J. Gerraty	@echo silent
25*06b9b3e0SSimon J. Gerraty	-echo ignerr; false
26*06b9b3e0SSimon J. Gerraty	+echo always
27