diff --git a/cmd/ipfs/add.go b/cmd/ipfs/add.go index ea1488055..209c3f42c 100644 --- a/cmd/ipfs/add.go +++ b/cmd/ipfs/add.go @@ -51,10 +51,7 @@ func addCmd(c *commander.Command, inp []string) error { return err } - err = commands.Add(n, cmd.Args, cmd.Opts, os.Stdout) - if err != nil { - fmt.Println(err) - } + return commands.Add(n, cmd.Args, cmd.Opts, os.Stdout) } return nil } diff --git a/cmd/ipfs/cat.go b/cmd/ipfs/cat.go index e965d4863..8d3d74f10 100644 --- a/cmd/ipfs/cat.go +++ b/cmd/ipfs/cat.go @@ -1,7 +1,6 @@ package main import ( - "fmt" "os" "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag" @@ -29,6 +28,11 @@ func catCmd(c *commander.Command, inp []string) error { return nil } + expanded, err := u.ExpandPathnames(inp) + if err != nil { + return err + } + com := daemon.NewCommand() com.Command = "cat" com.Args = inp @@ -40,10 +44,7 @@ func catCmd(c *commander.Command, inp []string) error { return err } - err = commands.Cat(n, com.Args, com.Opts, os.Stdout) - if err != nil { - fmt.Println(err) - } + return commands.Cat(n, com.Args, com.Opts, os.Stdout) } return nil } diff --git a/cmd/ipfs/ls.go b/cmd/ipfs/ls.go index 53077d6fb..33e85d8e9 100644 --- a/cmd/ipfs/ls.go +++ b/cmd/ipfs/ls.go @@ -43,10 +43,7 @@ func lsCmd(c *commander.Command, inp []string) error { return err } - err = commands.Ls(n, com.Args, com.Opts, os.Stdout) - if err != nil { - fmt.Println(err) - } + return commands.Ls(n, com.Args, com.Opts, os.Stdout) } return nil diff --git a/util/util.go b/util/util.go index 56a80b64b..9c17fe0e6 100644 --- a/util/util.go +++ b/util/util.go @@ -5,6 +5,7 @@ import ( "fmt" "os" "os/user" + "path/filepath" "strings" b58 "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58" @@ -78,3 +79,15 @@ func DOut(format string, a ...interface{}) { POut(format, a...) } } + +func ExpandPathnames(paths []string) ([]string, error) { + var out []string + for _, p := range paths { + abspath, err := filepath.Abs(p) + if err != nil { + return nil, err + } + out = append(out, abspath) + } + return out, nil +}