unlink.c 808 B

123456789101112131415161718192021222324252627282930313233
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * unlink for busybox
  4. *
  5. * Copyright (C) 2014 Isaac Dunham <ibid.ag@gmail.com>
  6. *
  7. * Licensed under GPLv2, see LICENSE in this source tree
  8. */
  9. //config:config UNLINK
  10. //config: bool "unlink (3.5 kb)"
  11. //config: default y
  12. //config: help
  13. //config: unlink deletes a file by calling unlink()
  14. //applet:IF_UNLINK(APPLET_NOFORK(unlink, unlink, BB_DIR_USR_BIN, BB_SUID_DROP, unlink))
  15. //kbuild:lib-$(CONFIG_UNLINK) += unlink.o
  16. //usage:#define unlink_trivial_usage
  17. //usage: "FILE"
  18. //usage:#define unlink_full_usage "\n\n"
  19. //usage: "Delete FILE by calling unlink()"
  20. #include "libbb.h"
  21. int unlink_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
  22. int unlink_main(int argc UNUSED_PARAM, char **argv)
  23. {
  24. getopt32(argv, "^" "" "\0" "=1");
  25. argv += optind;
  26. xunlink(argv[0]);
  27. return 0;
  28. }