gitlab.com/apertussolutions/u-root@v7.0.0+incompatible/cmds/core/dirname/dirname.go (about)

     1  // Copyright 2016-2017 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  // dirname prints out the directory name of one or more args.
     6  // If no arg is given it returns an error and prints a message which,
     7  // per the man page, is incorrect, but per the standard, is correct.
     8  package main
     9  
    10  import (
    11  	"fmt"
    12  	"log"
    13  	"os"
    14  	"path/filepath"
    15  )
    16  
    17  func main() {
    18  	if len(os.Args) < 2 {
    19  		log.Fatalf("dirname: missing operand")
    20  	}
    21  
    22  	for _, n := range os.Args[1:] {
    23  		fmt.Println(filepath.Dir(n))
    24  	}
    25  }