diff options
| author | Fumitoshi Ukai <ukai@google.com> | 2015-07-28 14:37:02 +0900 |
|---|---|---|
| committer | Fumitoshi Ukai <ukai@google.com> | 2015-07-28 14:38:24 +0900 |
| commit | f90f73c2f110e06789acf55ab260ee001770eed3 (patch) | |
| tree | d33bab34b473f909d8a9d4d5f74cb12f3101e8cf /ninja.go | |
| parent | 90216597c15473497b8564824465768ad1d67708 (diff) | |
[go] ignore export environment variable of space in name.
bash couldn't handle variable name with space for export.
Diffstat (limited to 'ninja.go')
| -rw-r--r-- | ninja.go | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -24,6 +24,8 @@ import ( "sort" "strings" "time" + + "github.com/golang/glog" ) // NinjaGenerator generates ninja build files from DepGraph. @@ -554,14 +556,17 @@ func (n *NinjaGenerator) generateShell() (err error) { fmt.Fprintf(f, "if [ -f %s ]; then\n export $(cat %s)\nfi\n", n.envlistName(), n.envlistName()) } for name, export := range n.exports { + // export "a b"=c will error on bash + // bash: export `a b=c': not a valid identifier + if strings.ContainsAny(name, " \t\n\r") { + glog.V(1).Infof("ignore export %q (export:%t)", name, export) + continue + } if export { v, err := n.ctx.ev.EvaluateVar(name) if err != nil { return err } - // TODO(ukai): if name contains space, ignore it? - // export "a b"=c will error on bash - // bash: export `a b=c': not a valid identifier fmt.Fprintf(f, "export %q=%q\n", name, v) } else { fmt.Fprintf(f, "unset %q\n", name) |
