From 413358abb915dd2cfd948f2f9a58b5bff3e672fe Mon Sep 17 00:00:00 2001 From: meowsbits <45600330+meowsbits@users.noreply.github.com> Date: Wed, 24 Jun 2020 15:01:58 -0500 Subject: [PATCH] cmd/geth: make import cmd exit with 1 if import errors occurred (#21244) The import command should not return a 0 status code if the import finishes prematurely becaues of an import error. Returning the error causes the program to exit with 1 if the err is non nil. Signed-off-by: meows --- cmd/geth/chaincmd.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go index ba2027217..3de7b2bdc 100644 --- a/cmd/geth/chaincmd.go +++ b/cmd/geth/chaincmd.go @@ -299,13 +299,17 @@ func importChain(ctx *cli.Context) error { // Import the chain start := time.Now() + var importErr error + if len(ctx.Args()) == 1 { if err := utils.ImportChain(chain, ctx.Args().First()); err != nil { + importErr = err log.Error("Import error", "err", err) } } else { for _, arg := range ctx.Args() { if err := utils.ImportChain(chain, arg); err != nil { + importErr = err log.Error("Import error", "file", arg, "err", err) } } @@ -358,7 +362,7 @@ func importChain(ctx *cli.Context) error { utils.Fatalf("Failed to read database iostats: %v", err) } fmt.Println(ioStats) - return nil + return importErr } func exportChain(ctx *cli.Context) error {