如何从Powershell中获取最新的Mercurial标签

Dan*_*nes 5 powershell mercurial

如果我从DOS提示符运行以下命令:

hg parents --template {latesttag}

然后我按预期返回最新的标签值.但是,如果我从powershell控制台中运行相同的命令,我会收到以下错误:

hg父母:选项-i无法识别

我需要在powershell中运行命令,因此我可以将结果作为要使用的变量.知道我需要做什么来运行命令吗?

Joe*_*ant 4

您只需要将参数括在--template引号中,以便 Powershell 知道它是一个字符串:

hg parents --template '{latesttag}'
Run Code Online (Sandbox Code Playgroud)

然而,有时,使用 Powershell 解析内容的方式,您必须双重确保双引号能够存在(例如传递包含空格的参数,但应该是 1 个参数而不是多个参数,例如路径或更长的模板):

hg parents --template '"{latesttag}"'
Run Code Online (Sandbox Code Playgroud)