github.com/system-transparency/u-root@v6.0.1-0.20190919065413-ed07a650de4c+incompatible/pkg/bb/bbmain/cmd/main.go (about)

     1  // Copyright 2018 the u-root Authors. All rights reserved
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // Package main is the busybox main.go template.
     6  package main
     7  
     8  import (
     9  	"log"
    10  	"os"
    11  	"path/filepath"
    12  
    13  	"github.com/u-root/u-root/pkg/bb/bbmain"
    14  	"github.com/u-root/u-root/pkg/uroot/util"
    15  )
    16  
    17  func run() {
    18  	name := filepath.Base(os.Args[0])
    19  	if err := bbmain.Run(name); err != nil {
    20  		log.Fatalf("%s: %v", name, err)
    21  	}
    22  }
    23  
    24  func main() {
    25  	os.Args[0] = util.ResolveUntilLastSymlink(os.Args[0])
    26  
    27  	run()
    28  }
    29  
    30  func init() {
    31  	m := func() {
    32  		// Use argv[1] as the name.
    33  		os.Args = os.Args[1:]
    34  		run()
    35  	}
    36  	bbmain.Register("bb", bbmain.Noop, m)
    37  	bbmain.RegisterDefault(bbmain.Noop, m)
    38  }