Skip to content

Commit

Permalink
fix: ensure empty keys are not added to the environment
Browse files Browse the repository at this point in the history
There appears to be cases where empty keys related to the basher path are injected into the env, causing identifier issues. This completely removes that possibiity.
  • Loading branch information
josegonzalez committed May 7, 2020
1 parent c5a2b04 commit 34e0bfd
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions basher.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,11 @@ func (c *Context) buildEnvfile() (string, error) {
file.Write([]byte("export SELF=" + os.Args[0] + "\n"))
file.Write([]byte("export SELF_EXECUTABLE='" + c.SelfPath + "'\n"))
for _, kvp := range c.vars {
pair := strings.SplitN(kvp, "=", 2)
if len(pair) != 2 || strings.TrimSpace(pair[0]) == "" {
continue
}

file.Write([]byte("export " + strings.Replace(
strings.Replace(kvp, "'", "\\'", -1), "=", "=$'", 1) + "'\n"))
}
Expand Down

0 comments on commit 34e0bfd

Please sign in to comment.