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