如何从Powershell中获取最新的Mercurial标签 [英] How do I get the latest Mercurial tag from within Powershell
问题描述
如果我从DOS提示符下运行以下命令:
If i run the following command from a DOS prompt:
hg父母--template {latesttag}
hg parents --template {latesttag}
然后我得到了按预期返回的最新标签值.但是,如果我在Powershell控制台中运行相同的命令,则会出现以下错误:
then I get the latest tag value returned as expected. However if I run the same command from within a powershell console I get the following error:
汞父母:选项-i无法识别
hg parents: option -i not recognized
我需要在Powershell中运行命令,以便将其结果作为变量使用.知道我需要做什么才能使命令运行吗?
I need the command to run in powershell so I can get it's results as a variable to use. Any idea what I need to do to get the command running?
推荐答案
您只需要将--template
的参数括在引号中,以使Powershell知道它是一个字符串:
You should just need to surround the argument to --template
in quotes so that Powershell knows it's a string:
hg parents --template '{latesttag}'
但是,有时候,通过Powershell解析事物的方式,您必须双重确保双引号能够保留(例如,传递包含空格但应为1的参数而不是多个参数,例如路径或更长的模板):
Sometimes, however, with the way Powershell parses things you have to make doubly sure that double-quotes survive (such as passing an argument that contains spaces but should be 1 argument instead of many, like paths or a longer template):
hg parents --template '"{latesttag}"'
这篇关于如何从Powershell中获取最新的Mercurial标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!