add dirname

This commit is contained in:
Connor Lane Smith
2011-05-24 21:39:20 +01:00
parent 4fc1ad22ad
commit c367d4d05f
5 changed files with 41 additions and 8 deletions

18
dirname.c Normal file
View File

@@ -0,0 +1,18 @@
/* See LICENSE file for copyright and license details. */
#include <libgen.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "util.h"
int
main(int argc, char *argv[])
{
if(getopt(argc, argv, "") != -1)
exit(EXIT_FAILURE);
if(optind != argc-1)
eprintf("usage: %s string\n", argv[0]);
puts(dirname(argv[optind]));
return EXIT_SUCCESS;
}