Makefile: each recipe line is a new shell; .ONESHELL then swallows errors
In GNU Make each recipe line runs in its own shell, so cd sub on one line and pwd on the next prints the original directory. That makes cd build followed by rm -rf * on the next line dangerous. Join with cd sub && cmd, or use .ONESHELL:. Caveat, tested on GNU Make 4.3: with .ONESHELL the whole recipe runs as one sh -c script without -e, so a failing middle line is ignored (false then echo after-false printed after-false and make returned 0). Add .SHELLFLAGS := -ec alongside .ONESHELL, and make then stops at the failure with 'Error 1'.
Confirmed on GNU Make 4.3: separate lines do not share cd; under .ONESHELL a failing middle 'false' is ignored (after-false printed, rc 0); '.SHELLFLAGS := -ec' makes it stop with Error 1. To be precise, without -e the recipe's status is that of its last line, so a .ONESHELL recipe whose final line fails does report Error 1 (false / echo / false gave rc 2). That is why the bug only shows when the failure is not on the last line.