在 PowerShell 中使用 YQ 时出现引用问题
Problems with quoting while using YQ in PowerShell
我正在尝试 运行 PowerShell 中的这个 yq 命令:
yq eval '.. | select(has(""CK_RUN_CASE""))' problemset.yml
但我收到此错误消息:
Error: open .. | select(has("CK_RUN_CASE)) problemset.yml: The filename, directory name, or volume label syntax is incorrect.
我试图遵循这个提示,但没有成功:
https://mikefarah.gitbook.io/yq/usage/tips-and-tricks#quotes-in-windows-powershell
它在我的 Ubuntu 机器上运行,引号如下:
yq eval '.. | select(has("CK_RUN_CASE"))' problemset.yml
但出于某些原因,我真的需要它在我的 Windows 机器上工作。有什么建议吗?
使用这个测试文件:
# problemset.yml
CK_RUN_CASE: foo
array:
- CK_RUN_CASE: bar
在 powershell 中三重引用密钥名称似乎可行:
$ yq eval '.. | select(has("""CK_RUN_CASE"""))' problemset.yml
CK_RUN_CASE: foo
array:
- CK_RUN_CASE: bar
CK_RUN_CASE: bar
转义双引号也是如此:
$ yq eval '.. | select(has(\"CK_RUN_CASE\"))' problemset.yml
CK_RUN_CASE: foo
array:
- CK_RUN_CASE: bar
CK_RUN_CASE: bar
但是,我找不到同时适用于 powershell 和 WSL/linux...
的语法
我正在尝试 运行 PowerShell 中的这个 yq 命令:
yq eval '.. | select(has(""CK_RUN_CASE""))' problemset.yml
但我收到此错误消息:
Error: open .. | select(has("CK_RUN_CASE)) problemset.yml: The filename, directory name, or volume label syntax is incorrect.
我试图遵循这个提示,但没有成功: https://mikefarah.gitbook.io/yq/usage/tips-and-tricks#quotes-in-windows-powershell
它在我的 Ubuntu 机器上运行,引号如下:
yq eval '.. | select(has("CK_RUN_CASE"))' problemset.yml
但出于某些原因,我真的需要它在我的 Windows 机器上工作。有什么建议吗?
使用这个测试文件:
# problemset.yml
CK_RUN_CASE: foo
array:
- CK_RUN_CASE: bar
在 powershell 中三重引用密钥名称似乎可行:
$ yq eval '.. | select(has("""CK_RUN_CASE"""))' problemset.yml
CK_RUN_CASE: foo
array:
- CK_RUN_CASE: bar
CK_RUN_CASE: bar
转义双引号也是如此:
$ yq eval '.. | select(has(\"CK_RUN_CASE\"))' problemset.yml
CK_RUN_CASE: foo
array:
- CK_RUN_CASE: bar
CK_RUN_CASE: bar
但是,我找不到同时适用于 powershell 和 WSL/linux...
的语法