From 8b074767db0df29a43bc0a994414b9eb280a8f7a Mon Sep 17 00:00:00 2001 From: Anis Elleuch Date: Sat, 21 May 2016 00:43:06 +0100 Subject: [PATCH] ls: list objects inside a directory when this latter is passed without a trailing separator (#1724) --- ls-main.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ls-main.go b/ls-main.go index 6b4016c2..e3d7a256 100644 --- a/ls-main.go +++ b/ls-main.go @@ -135,6 +135,15 @@ func mainList(ctx *cli.Context) { clnt, err := newClient(targetURL) fatalIf(err.Trace(targetURL), "Unable to initialize target ‘"+targetURL+"’.") + st, err := clnt.Stat() + fatalIf(err.Trace(targetURL), "Unable to stat target ‘"+targetURL+"’.") + + if st.Type.IsDir() { + targetURL = targetURL + string(clnt.GetURL().Separator) + clnt, err = newClient(targetURL) + fatalIf(err.Trace(targetURL), "Unable to initialize target ‘"+targetURL+"’.") + } + err = doList(clnt, isRecursive, isIncomplete) if err != nil { errorIf(err.Trace(clnt.GetURL().String()), "Unable to list target ‘"+clnt.GetURL().String()+"’.")