diff options
author | Amis Shokoohi <[email protected]> | 2023-01-31 19:54:44 +0330 |
---|---|---|
committer | GitHub <[email protected]> | 2023-01-31 11:24:44 -0500 |
commit | 8c0b49bf039bc0b6ab72b44ef0e1e6587c76ad2b (patch) | |
tree | 9edfbfb4a2292fbfdf45c7091fc454489d45ed73 /cmd | |
parent | 201b9b41f98aa28d7d0ad223bf3614b78312690d (diff) | |
download | caddy-8c0b49bf039bc0b6ab72b44ef0e1e6587c76ad2b.tar.gz caddy-8c0b49bf039bc0b6ab72b44ef0e1e6587c76ad2b.zip |
cmd: `fmt` exit successfully after overwriting config file (#5351)
Fixes https://github.com/caddyserver/caddy/issues/5349
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/commandfuncs.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/cmd/commandfuncs.go b/cmd/commandfuncs.go index bc4c22781..c5264ed41 100644 --- a/cmd/commandfuncs.go +++ b/cmd/commandfuncs.go @@ -558,7 +558,10 @@ func cmdFmt(fl Flags) (int, error) { if err := os.WriteFile(formatCmdConfigFile, output, 0600); err != nil { return caddy.ExitCodeFailedStartup, fmt.Errorf("overwriting formatted file: %v", err) } - } else if fl.Bool("diff") { + return caddy.ExitCodeSuccess, nil + } + + if fl.Bool("diff") { diff := difflib.Diff( strings.Split(string(input), "\n"), strings.Split(string(output), "\n")) |