Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
008ed531a2
|
|||
|
cf67bec392
|
|||
|
0e194a07f4
|
@@ -1,11 +1,11 @@
|
||||
package envs
|
||||
|
||||
import (
|
||||
`regexp`
|
||||
"regexp"
|
||||
)
|
||||
|
||||
// Compiled regex patterns.
|
||||
var (
|
||||
reMaybeInt *regexp.Regexp = regexp.MustCompilePOSIX(`^(?P<sign>\+|-)[0-9]+$`)
|
||||
reMaybeFloat *regexp.Regexp = regexp.MustCompilePOSIX(`(?P<sign>\+|-)?[0-9]+\.[0-9]+$`)
|
||||
reMaybeInt *regexp.Regexp = regexp.MustCompile(`^(?P<sign>\+|-)[0-9]+$`)
|
||||
reMaybeFloat *regexp.Regexp = regexp.MustCompile(`(?P<sign>\+|-)?[0-9]+\.[0-9]+$`)
|
||||
)
|
||||
|
||||
@@ -16,8 +16,8 @@ func envListToMap(envs []string) (envMap map[string]string) {
|
||||
envMap = make(map[string]string, 0)
|
||||
|
||||
for _, ev := range envs {
|
||||
kv = strings.SplitAfterN(ev, "=", 2)
|
||||
// I *think* SplitAfterN does this for me, but...
|
||||
kv = strings.SplitN(ev, "=", 2)
|
||||
// I *think* SplitN does this for me, but...
|
||||
if len(kv) == 1 {
|
||||
kv = append(kv, "")
|
||||
}
|
||||
@@ -35,6 +35,8 @@ func nativizeEnvMap(stringMap map[string]string) (envMap map[string]interface{})
|
||||
var pathVar string = internal.GetPathEnvName()
|
||||
var err error
|
||||
|
||||
envMap = make(map[string]interface{}, 0)
|
||||
|
||||
for k, v := range stringMap {
|
||||
|
||||
// Check for PATH/Path - we handle this uniquely.
|
||||
|
||||
@@ -62,7 +62,7 @@ func ExpandHome(path *string) (err error) {
|
||||
}
|
||||
*/
|
||||
// K but do it smarter.
|
||||
unameSplit = strings.SplitAfterN(*path, string(os.PathSeparator), 2)
|
||||
unameSplit = strings.SplitN(*path, string(os.PathSeparator), 2)
|
||||
if len(unameSplit) != 2 {
|
||||
unameSplit = append(unameSplit, "")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user