Makefile: How to assign a command's output and exit code to a variable?

后端 未结 2 1400
终归单人心
终归单人心 2021-01-15 05:55

I am searching for a way to get the output and the exit code of a command to variables in a makefile.

Basicly I want this: (bash)



        
2条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-15 06:18

    If you are going to use eval anyway, make it print things you can eval directly.

    $(eval $(shell echo OUTPUT_RC=`whoami`; echo $$?))
    OUTPUT=$(word 1,$(OUTPUT_RC))
    RC=$(word 2,$(OUTPUT_RC))
    

提交回复
热议问题