Skip to content

Commit

Permalink
make argument handling (slightly) more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
mvo5 committed Jun 22, 2017
1 parent a135a71 commit dde3e76
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cmd/snap-seccomp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -640,17 +640,26 @@ 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
}

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
Expand Down

0 comments on commit dde3e76

Please sign in to comment.