How to make GNU Make fail if a shell command assigned to a variable failed?

后端 未结 3 1376
别跟我提以往
别跟我提以往 2020-12-20 08:55

I have a Make variable:

PASSWORD:=$(shell vault read -field=password test/password)

If vault is not installed, make

3条回答
  •  无人及你
    2020-12-20 09:20

    Maybe this idea should work:

    X!=lsx /
    
    all:
    ifeq (${.SHELLSTATUS},0)
        @echo OK
    else
        @exit 1
    endif
    

    For example you can create a check: PHONY-target which is needed by every (other) target.

    Explanation see here:

    After the shell function or ‘!=’ assignment operator is used, its exit status is placed in the .SHELLSTATUS variable.

    The X=$(shell ls /) doesn't work but IMHO should.

提交回复
热议问题