下面是我试图开始工作的powershell脚本。它设计为使用GitHub for Windows git shell运行,我试图称之为“Hub”(https://github.com/github/hub),但那不相关。我可以称之为正常,除了命令行参数之一我想要一些换行符。有办法做到这一点吗?新行被解释为命令的结束。
换行符是$ msg变量。所以(缩写)输出类似于:
hub pull-request -m "PFR-1
https://linktoitem/PFR-1
"
但命令行只看到:hub pull-request -m“PFR-1
$branch = $Global:GitStatus.branch
$segments = $branch.split("/")
iex "git push -u origin $branch"
if ($segments.Length -eq 2 -and $segments[1] -match "^\w+\-\d+$")
{
$jiraItem = $segments[1].ToUpper()
$msg = "$jiraItem`r`n``r`nnhttps://someurl.atlassian.net/browse/$jiraItem"
echo "hub pull-request -m ""$msg"" -b kiandra-projects:develop -h kiandra-projects:$branch"
iex "& hub pull-request -m ""$msg"" -b kiandra-projects:develop -h kiandra-projects:$branch"
}
else
{
iex "hub pull-request -b kiandra-projects:develop -h kiandra-projects:$branch"
}
答案 0 :(得分:0)
你试过一个here-string吗?
$MultilineString = @"
Stuff
More stuff
"@
# in your case:
$msg = @"
$jiraItem
https://someurl.atlassian.net/browse/$jiraItem
"@
注意:结束"@
必须在其自己的行
另外,请检查http://chocolatey.org/packages/Posh-GitHub,它可能会执行您需要的操作