From afab235477a80b0ca6c593a637b9ea1ab0ec1ba2 Mon Sep 17 00:00:00 2001 From: Maximilian Meister Date: Sat, 18 Nov 2017 16:35:27 +0100 Subject: [PATCH] cmd/geth: fix passing datadir flag to attach subcommand the datadir flag wasn't respected, instead you had to provide an additional argument, which was unclear from a usage point of view Signed-off-by: Maximilian Meister --- cmd/geth/consolecmd.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmd/geth/consolecmd.go b/cmd/geth/consolecmd.go index 2bb452d73611..051962be47e5 100644 --- a/cmd/geth/consolecmd.go +++ b/cmd/geth/consolecmd.go @@ -17,6 +17,7 @@ package main import ( + "fmt" "os" "os/signal" "strings" @@ -112,7 +113,11 @@ func localConsole(ctx *cli.Context) error { // console to it. func remoteConsole(ctx *cli.Context) error { // Attach to a remotely running geth instance and start the JavaScript console - client, err := dialRPC(ctx.Args().First()) + endpoint := ctx.Args().First() + if endpoint == "" && ctx.GlobalIsSet(utils.DataDirFlag.Name) { + endpoint = fmt.Sprintf("%s/geth.ipc", ctx.GlobalString(utils.DataDirFlag.Name)) + } + client, err := dialRPC(endpoint) if err != nil { utils.Fatalf("Unable to attach to remote geth: %v", err) }