Skip to content

MF_NON_INTERACTIVE does not seem to work at all #77

@ezzatron

Description

@ezzatron

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions