Bim*_*mme 0 git makefile substring
我有一个使用以下方法提取的 git 哈希字符串:
git describe --always --abbrev=6
即我想得到 6 个字符。问题是如果 6 个字符的标签不是唯一的,git 似乎给了我 7 个字符。所以我想使用标准的 make / bash 命令(如 sed)提取前 6 个字符。make 本身似乎不支持子字符串。
目前我的 make 脚本包含以下内容:
foo:=$(lastword $(subst M,,$(subst :, ,$(shell git describe --always --abbrev=6))))
这可能导致 foo=e94181c 但我喜欢它只是 e94181 以适应 24 位内存区域。
我可能会这样做:
foo := $(shell git describe --always --abbrev=6 | cut -c 1-6)