master xplshn/aruu / cmd / posix / dirname.c
 1/* See LICENSE file for copyright and license details. */
 2
 3#include <libgen.h>
 4#include <stdio.h>
 5
 6#include "util.h"
 7
 8static void
 9usage(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
17int
18main(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}