Currently we manually set MF_NON_INTERACTIVE to true under CI, and try to detect it otherwise. But I'm pretty sure the detection is not working at all. After looking into it, I'm not even sure it's possible to detect an interactive shell under make. None of the suggestions I have seen hold up to actual testing (e.g. https://stackoverflow.com/questions/4251559/how-can-i-tell-if-a-makefile-is-being-run-from-an-interactive-shell).
Unless @jmalloc you have any ideas about how to actually detect non-interactivity under make, perhaps we should either:
- Stop passing "non-interactive" options to commands completely, and let the individual commands handle it; OR
- Always pass "non-interactive" options to commands; OR
- Always pass "non-interactive" options to commands under CI, but never outside of CI
The following Makefile:
DEFAULT_GOAL := test
export EXAMPLE_A := $(shell [ -t 0 ] || echo true)
export EXAMPLE_B := $(shell [[ $$- == *i* ]] && echo true)
export EXAMPLE_C := $(shell echo $$-)
test:
echo "EXAMPLE_A=$(EXAMPLE_A)"
echo "EXAMPLE_B=$(EXAMPLE_B)"
echo "EXAMPLE_C=$(EXAMPLE_C)"
Gives the following output under various interactive and non-interactive circumstances:
$ make
echo "EXAMPLE_A="
EXAMPLE_A=
echo "EXAMPLE_B="
EXAMPLE_B=
echo "EXAMPLE_C=hBc"
EXAMPLE_C=hBc
$ bash -c make
echo "EXAMPLE_A="
EXAMPLE_A=
echo "EXAMPLE_B="
EXAMPLE_B=
echo "EXAMPLE_C=hBc"
EXAMPLE_C=hBc
$ make > /dev/stdout
echo "EXAMPLE_A="
EXAMPLE_A=
echo "EXAMPLE_B="
EXAMPLE_B=
echo "EXAMPLE_C=hBc"
EXAMPLE_C=hBc
Currently we manually set
MF_NON_INTERACTIVEtotrueunder CI, and try to detect it otherwise. But I'm pretty sure the detection is not working at all. After looking into it, I'm not even sure it's possible to detect an interactive shell undermake. None of the suggestions I have seen hold up to actual testing (e.g. https://stackoverflow.com/questions/4251559/how-can-i-tell-if-a-makefile-is-being-run-from-an-interactive-shell).Unless @jmalloc you have any ideas about how to actually detect non-interactivity under
make, perhaps we should either:The following Makefile:
Gives the following output under various interactive and non-interactive circumstances: