Skip to content

*NIX系统下通过shell对命令形式的变量表达式进行求值 #34

Description

@voidint
{
    "version": "0.5.0",
    "tool": "go build  -ldflags='-s -w' -gcflags='-N -l'",
    "importpath": "github.com/voidint/gbb/build",
    "variables": [
        {
            "variable": "Branch",
            "value": "$(git branch | grep '*' | awk {'print $2'})"
        }
    ]
}

对于git branch | grep '*' | awk {'print $2'}这种由多个命令组合而成的复杂命令表达式,显然无法直接使用exec.Command()来获得最终结果。而通过shell来执行此类复杂命令,却可以极大简化整个表达式求值过程。

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions