2000-03-05 08:07:00 +00:00
|
|
|
/* vi: set sw=4 ts=4: */
|
|
|
|
/*
|
2000-04-13 18:49:43 +00:00
|
|
|
* Mini dirname implementation for busybox
|
|
|
|
*
|
2004-03-15 08:29:22 +00:00
|
|
|
* Copyright (C) 1999-2004 by Erik Andersen <andersen@codepoet.org>
|
2000-04-13 18:49:43 +00:00
|
|
|
*
|
2010-08-16 18:14:46 +00:00
|
|
|
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
2000-03-05 08:07:00 +00:00
|
|
|
*/
|
2016-11-23 13:46:56 +00:00
|
|
|
//config:config DIRNAME
|
2018-12-28 02:20:17 +00:00
|
|
|
//config: bool "dirname (329 bytes)"
|
2016-11-23 13:46:56 +00:00
|
|
|
//config: default y
|
|
|
|
//config: help
|
2017-07-21 07:50:55 +00:00
|
|
|
//config: dirname is used to strip a non-directory suffix from
|
|
|
|
//config: a file name.
|
2016-11-23 13:46:56 +00:00
|
|
|
|
|
|
|
//applet:IF_DIRNAME(APPLET_NOFORK(dirname, dirname, BB_DIR_USR_BIN, BB_SUID_DROP, dirname))
|
|
|
|
|
|
|
|
//kbuild:lib-$(CONFIG_DIRNAME) += dirname.o
|
2001-02-20 06:14:08 +00:00
|
|
|
|
2003-03-19 09:13:01 +00:00
|
|
|
/* BB_AUDIT SUSv3 compliant */
|
|
|
|
/* http://www.opengroup.org/onlinepubs/007904975/utilities/dirname.html */
|
2001-03-09 23:59:51 +00:00
|
|
|
|
2011-03-31 12:43:25 +00:00
|
|
|
//usage:#define dirname_trivial_usage
|
|
|
|
//usage: "FILENAME"
|
|
|
|
//usage:#define dirname_full_usage "\n\n"
|
|
|
|
//usage: "Strip non-directory suffix from FILENAME"
|
|
|
|
//usage:
|
|
|
|
//usage:#define dirname_example_usage
|
|
|
|
//usage: "$ dirname /tmp/foo\n"
|
|
|
|
//usage: "/tmp\n"
|
|
|
|
//usage: "$ dirname /tmp/foo/\n"
|
|
|
|
//usage: "/tmp\n"
|
|
|
|
|
2007-05-26 19:00:18 +00:00
|
|
|
#include "libbb.h"
|
2000-03-05 08:07:00 +00:00
|
|
|
|
2007-04-10 15:43:37 +00:00
|
|
|
/* This is a NOFORK applet. Be very careful! */
|
|
|
|
|
2007-10-11 10:05:36 +00:00
|
|
|
int dirname_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
2009-11-28 14:18:53 +00:00
|
|
|
int dirname_main(int argc UNUSED_PARAM, char **argv)
|
2000-03-05 08:07:00 +00:00
|
|
|
{
|
2009-11-28 14:18:53 +00:00
|
|
|
puts(dirname(single_argv(argv)));
|
2009-11-02 13:19:51 +00:00
|
|
|
return fflush_all();
|
2000-03-05 08:07:00 +00:00
|
|
|
}
|