blob: 4ecde3147daf578673ef8fde0bd89ff37b20e989 [file] [log] [blame]
Erik Andersenfb002d02000-03-05 08:07:00 +00001/* vi: set sw=4 ts=4: */
2/*
Erik Andersen9cf3bfa2000-04-13 18:49:43 +00003 * Mini dirname implementation for busybox
Erik Andersenfb002d02000-03-05 08:07:00 +00004 *
Eric Andersenc7bda1c2004-03-15 08:29:22 +00005 * Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
Erik Andersenfb002d02000-03-05 08:07:00 +00006 *
"Robert P. J. Day"801ab142006-07-12 07:56:04 +00007 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
Erik Andersenfb002d02000-03-05 08:07:00 +00008 */
Eric Andersencbe31da2001-02-20 06:14:08 +00009
Manuel Novoa III cad53642003-03-19 09:13:01 +000010/* BB_AUDIT SUSv3 compliant */
11/* http://www.opengroup.org/onlinepubs/007904975/utilities/dirname.html */
Mark Whitley827e45c2001-03-09 23:59:51 +000012
Erik Andersenfb002d02000-03-05 08:07:00 +000013#include <stdio.h>
Eric Andersened3ef502001-01-27 08:24:39 +000014#include <stdlib.h>
Eric Andersencbe31da2001-02-20 06:14:08 +000015#include "busybox.h"
Erik Andersenfb002d02000-03-05 08:07:00 +000016
Denis Vlasenko06af2162007-02-03 17:28:39 +000017int dirname_main(int argc, char **argv);
Rob Landleydfba7412006-03-06 20:47:33 +000018int dirname_main(int argc, char **argv)
Erik Andersenfb002d02000-03-05 08:07:00 +000019{
Manuel Novoa III cad53642003-03-19 09:13:01 +000020 if (argc != 2) {
21 bb_show_usage();
22 }
Erik Andersenfb002d02000-03-05 08:07:00 +000023
Manuel Novoa III cad53642003-03-19 09:13:01 +000024 puts(dirname(argv[1]));
Matt Kraaiceeff732001-06-21 19:41:37 +000025
Denis Vlasenkof0ed3762006-10-26 23:21:47 +000026 fflush_stdout_and_exit(EXIT_SUCCESS);
Erik Andersenfb002d02000-03-05 08:07:00 +000027}