aruu

[MIRROR] Actual replacement for Busybox | suckless
git clone https://git.daat.foo/aruu.git
Log | Files | Refs | README | LICENSE

dirname.c (504B)


      1 /* see LICENSE file for copyright and license details */
      2 
      3 #include <libgen.h>
      4 #include <stdio.h>
      5 
      6 #include "util.h"
      7 
      8 static void
      9 usage(void)
     10 {
     11   eprintf("usage: %s path\n", argv0);
     12 }
     13 
     14 // ?man dirname: strip non-directory suffix from filename
     15 // ?man arguments: path
     16 // ?man print the directory portion of a pathname
     17 int
     18 main(int argc, char *argv[])
     19 {
     20   ARGBEGIN
     21   {
     22     default:
     23       usage();
     24   }
     25   ARGEND
     26 
     27   if (argc != 1)
     28     usage();
     29 
     30   puts(dirname(argv[0]));
     31 
     32   return fshut(stdout, "<stdout>");
     33 }