using $(shell some sh command) when .SHELL has been (temporarily) set to non

"Cook, Malcolm" <[email protected]> Thu, 3 Apr 2025 19:34:10 +0000
Newsgroups gmane.comp.gnu.make.general
Message-ID <DS7PR20MB46711F842FDF9C1D3108C7D7BEAE2@DS7PR20MB4671.namprd20.prod.outlook.com>
I expect GNU make is working as expected, but I could use confirmation ....

I was surprised when setting SHELL (e.g. to `duckdb`) to find that a simply expanded variable that expands to $(shell some sh command) wound up passing 'my sh command' to duckdb rather than /bin/sh since It was expanded as part of a recipe that sets SHELL as a target specific variable for that recipe.

Should this behavior be considered "by design"?

My workaround was to instead use $(call sh,some sh command), where sh is defined as:

sh=$(let SHELL .SHELLFLAGS,/bin/sh -eu -o pipefail -c,$(shell $1))

Is there perhaps a better workaround?