From dde3e76be9bccd7507d557b11080d6422fe8aed1 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 22 Jun 2017 14:48:47 +0200 Subject: [PATCH] make argument handling (slightly) more robust --- cmd/snap-seccomp/main.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cmd/snap-seccomp/main.go b/cmd/snap-seccomp/main.go index a52df7c77db..4dab3487347 100644 --- a/cmd/snap-seccomp/main.go +++ b/cmd/snap-seccomp/main.go @@ -640,7 +640,7 @@ func compile(content []byte, out string) error { func showSeccompLibraryVersion() error { major, minor, micro := seccomp.GetLibraryVersion() - fmt.Fprintf(os.Stdout, "seccomp version: %d.%d.%d\n", major, minor, micro) + fmt.Fprintf(os.Stdout, "%d.%d.%d\n", major, minor, micro) return nil } @@ -648,9 +648,18 @@ func main() { var err error var content []byte + if len(os.Args) < 2 { + fmt.Printf("%s: need a command\n", os.Args[0]) + os.Exit(1) + } + cmd := os.Args[1] switch cmd { case "compile": + if len(os.Args) < 4 { + fmt.Println("compile needs an input and output file") + os.Exit(1) + } content, err = ioutil.ReadFile(os.Args[2]) if err != nil { break