小编adr*_*nne的帖子

字符串比较在PowerShell函数中不起作用 - 我做错了什么?

我正在尝试创建别名,git commit并将消息记录到单独的文本文件中.但是,如果git commit返回"nothing to commit (working directory clean)",则不应将任何内容记录到单独的文件中.

这是我的代码.该git commit别名作品; 输出到文件的工作原理.但是,无论返回什么内容,它都会记录消息git commit.

function git-commit-and-log($msg)
{
    $q = git commit -a -m $msg
    $q
    if ($q –notcontains "nothing to commit") {
        $msg | Out-File w:\log.txt -Append
    }
}

Set-Alias -Name gcomm -Value git-commit-and-log
Run Code Online (Sandbox Code Playgroud)

我正在使用PowerShell 3.

windows git shell powershell scripting

5
推荐指数
1
解决办法
2万
查看次数

标签 统计

git ×1

powershell ×1

scripting ×1

shell ×1

windows ×1