bash - Makefile括号处理问题
问题描述
试图弄清楚如何处理 Makefile 中的“)”,但找不到任何示例
这是我必须处理的问题的一个简单示例,即在降价文件中提取用户列表
如果我在 bash 中这样做
echo '[ted toe](https://somewhere/users/tedtoe)' | awk -F '[/)]' '{print $5}'
我按预期得到了 tedtoe
但是当我尝试使用这个 Makefile
SHELL=/bin/bash
OWNERS := $(shell echo '[ted toe](https://somewhere/users/tedtoe)' | awk -F '[/)]' '{print $$5}')
owners:
@echo "The owners are ${OWNERS}"
我得到以下输出
/bin/bash: -c: line 0: unexpected EOF while looking for matching `''
/bin/bash: -c: line 1: syntax error: unexpected end of file
The owners are
当我尝试使用“)”作为字段分隔符时,它会失败我也尝试过管道和使用tr -d ')'
,但这也失败了
任何人都必须处理 make 文件中的括号问题?
解决方案
在解析您的OWNERS
定义时,make 解释右括号并将右括号'[/)]'
视为关闭$(shell ...)
. 改用 make 变量:
CP := )
OWNERS := $(shell echo '[ted toe](https://somewhere/users/tedtoe)' | awk -F '[/$(CP)]' '{print $$5}')
推荐阅读
- c# - 在 Razor 页面中调用操作
- r - 按列合并具有重复值的小标题
- jenkins - 如何在安装新插件之前进行詹金斯备份
- python - 如何在 python 中不使用多个 if/else 语句多次生成随机列表?
- javascript - Vue.JS 连续发送请求 - Websocket
- python - 尝试导入熊猫时如何修复“ModuleNotFoundError”
- arrays - 如何将单词数组转换为句子?
- c# - C# 如何使用 MVVM 模式恢复对话框中的更改
- c - 多线程 (C) 时 recvfrom() 返回的错误 10022
- java - 如何检查字符串是否在任何位置的给定字符串中包含三个连续顺序的字符?