MCPcopy
hub / github.com/dgraph-io/dgraph / shellOutput

Function shellOutput

buildvars/buildvars.go:47–53  ·  view source on GitHub ↗

shellOutput runs cmd with args, captures stdout, and returns it stripped of trailing whitespace. Returns empty on error: for example, when the command is missing (git absent) or the working directory lacks a git repo. Used by the derived Vars whose defaults are git metadata.

(cmd string, args ...string)

Source from the content-addressed store, hash-verified

45// command is missing (git absent) or the working directory lacks a git
46// repo. Used by the derived Vars whose defaults are git metadata.
47func shellOutput(cmd string, args ...string) string {
48 out, err := exec.Command(cmd, args...).Output()
49 if err != nil {
50 return ""
51 }
52 return strings.TrimSpace(string(out))
53}
54
55// Var is a single build-configuration environment variable. It bundles
56// the env-var name (Name) with a defaulter: either a literal fall-through

Callers 1

buildvars.goFile · 0.85

Calls 1

OutputMethod · 0.80

Tested by

no test coverage detected