blob: 61b108a84f42e3826dd4026396de0f316c3e5a17 [file] [log] [blame]
Isaac Dunhamea23c252014-06-22 20:44:25 +02001/* vi: set sw=4 ts=4: */
Denys Vlasenkoa02a4e92017-10-05 15:19:25 +02002/*
3 * unlink for busybox
Isaac Dunhamea23c252014-06-22 20:44:25 +02004 *
5 * Copyright (C) 2014 Isaac Dunham <ibid.ag@gmail.com>
6 *
7 * Licensed under GPLv2, see LICENSE in this source tree
8 */
Isaac Dunhamea23c252014-06-22 20:44:25 +02009//config:config UNLINK
Denys Vlasenko4eed2c62017-07-18 22:01:24 +020010//config: bool "unlink (3.5 kb)"
Isaac Dunhamea23c252014-06-22 20:44:25 +020011//config: default y
12//config: help
Denys Vlasenko72089cf2017-07-21 09:50:55 +020013//config: unlink deletes a file by calling unlink()
Isaac Dunhamea23c252014-06-22 20:44:25 +020014
Denys Vlasenko819b47a2017-08-03 03:29:32 +020015//applet:IF_UNLINK(APPLET_NOFORK(unlink, unlink, BB_DIR_USR_BIN, BB_SUID_DROP, unlink))
Isaac Dunhamea23c252014-06-22 20:44:25 +020016
Denys Vlasenkoaf3f4202016-11-23 14:46:56 +010017//kbuild:lib-$(CONFIG_UNLINK) += unlink.o
18
Isaac Dunhamea23c252014-06-22 20:44:25 +020019//usage:#define unlink_trivial_usage
20//usage: "FILE"
21//usage:#define unlink_full_usage "\n\n"
22//usage: "Delete FILE by calling unlink()"
23
24#include "libbb.h"
25
26int unlink_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
27int unlink_main(int argc UNUSED_PARAM, char **argv)
28{
Denys Vlasenko22542ec2017-08-08 21:55:02 +020029 getopt32(argv, "^" "" "\0" "=1");
Isaac Dunhamea23c252014-06-22 20:44:25 +020030 argv += optind;
31 xunlink(argv[0]);
32 return 0;
33}