On Sun, 2022-05-29 at 11:50 -0400, Pierre Rouleau wrote: > On Sat, May 28, 2022 at 2:11 AM Kaz Kylheku <k...@kylheku.com> wrote: > > What you probably want is to generate clauses joined by && > > > > $(foreach ....) --> patch < this && patch < that && ... && patch > > < last > > > > You mean unroll the loop manually? > Unfortunately the file I'm dealing with is part of a *large* build > system with over 2000 make file, with make recursion and multi-layer > decision making that end up building the list of patch files, > storing it inside a variable. > > Are you also saying that adding `|| exit 1' to the statement inside > the foreach loop would not work? > ie as in: > (cd $(OUTPUT_ROOT_DIR)/$(CFG_GLOBAL_LINUX_VERSION); $(foreach > thepatch,$(KERNEL_PATCH_ONE),echo patching $(thepatch); patch > --ignore-whitespace -p1 < $(thepatch) || exit 1;))
It will work. It's simple to test so did you try it and it didn't work and that's why you're asking? But I don't understand why the method Kaz suggests wouldn't work. If you can change the loop to add "|| exit 1;" after each patch command why can't you change the loop to add "&&" between each patch command? It would be something like: $(foreach p,$(KERNEL_PATCH_ONE),echo patching $p && patch ... < $p &&) true The advantage of the "&&" is that your script is shorter which means you'll be less likely to run into a limit for lots of patches (although the limits in modern POSIX systems are pretty large). > In the end do you mean that all I could do is prepend the rule with > `set -e; ' and that would ensure termination on the first error? > As in: > set -e; (cd $(OUTPUT_ROOT_DIR)/$(CFG_GLOBAL_LINUX_VERSION); > $(foreach thepatch,$(KERNEL_PATCH_ONE),echo patching $(thepatch); > patch > --ignore-whitespace -p1 < $(thepatch))) You need a semicolon after the patch command but yes, this will work as well.