Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

我想实现一个非root用户才能调用的makefile,但是在编写过程中出错了,不知道怎么解决

user := $(shell whoami)

ifeq ($(user), root)
    echo "You can't use root user!" && exit 1
else
    echo $(user)
endif

echo $(user) 这句报语法错误 *** commands commence before first target. Stop.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
455 views
Welcome To Ask or Share your Answers For Others

1 Answer

首先,makefile并不是bash脚本,不适合做这种条件判断的处理,你不妨写一个脚本


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...