diff options
Diffstat (limited to 'contrib/environment-to-ini')
-rw-r--r-- | contrib/environment-to-ini/environment-to-ini.go | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/contrib/environment-to-ini/environment-to-ini.go b/contrib/environment-to-ini/environment-to-ini.go index 74379e26af..aade251902 100644 --- a/contrib/environment-to-ini/environment-to-ini.go +++ b/contrib/environment-to-ini/environment-to-ini.go @@ -110,6 +110,8 @@ func runEnvironmentToIni(c *cli.Context) error { } cfg.NameMapper = ini.SnackCase + changed := false + prefix := c.String("prefix") + "__" for _, kv := range os.Environ() { @@ -143,15 +145,21 @@ func runEnvironmentToIni(c *cli.Context) error { continue } } + oldValue := key.Value() + if !changed && oldValue != value { + changed = true + } key.SetValue(value) } destination := c.String("out") if len(destination) == 0 { destination = setting.CustomConf } - err = cfg.SaveTo(destination) - if err != nil { - return err + if destination != setting.CustomConf || changed { + err = cfg.SaveTo(destination) + if err != nil { + return err + } } if c.Bool("clear") { for _, kv := range os.Environ() { |