aboutsummaryrefslogtreecommitdiff
path: root/ninja.go
diff options
context:
space:
mode:
authorFumitoshi Ukai <ukai@google.com>2015-07-28 14:37:02 +0900
committerFumitoshi Ukai <ukai@google.com>2015-07-28 14:38:24 +0900
commitf90f73c2f110e06789acf55ab260ee001770eed3 (patch)
treed33bab34b473f909d8a9d4d5f74cb12f3101e8cf /ninja.go
parent90216597c15473497b8564824465768ad1d67708 (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.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/ninja.go b/ninja.go
index e563fd9..360bfde 100644
--- a/ninja.go
+++ b/ninja.go
@@ -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)