Skip to content

Commit

Permalink
Merge pull request #28 from progrium/remove-empty-keys
Browse files Browse the repository at this point in the history
Ensure empty keys are not added to the environment
  • Loading branch information
josegonzalez authored May 7, 2020
2 parents c5a2b04 + 34e0bfd commit 7aca703
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 7aca703

Please sign in to comment.