pwd.c 573 B

123456789101112131415161718192021222324252627
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * Mini pwd implementation for busybox
  4. *
  5. * Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>.
  6. *
  7. * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
  8. */
  9. #include "libbb.h"
  10. /* This is a NOFORK applet. Be very careful! */
  11. int pwd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
  12. int pwd_main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
  13. {
  14. char *buf;
  15. buf = xrealloc_getcwd_or_warn(NULL);
  16. if (buf != NULL) {
  17. puts(buf);
  18. free(buf);
  19. return fflush(stdout);
  20. }
  21. return EXIT_FAILURE;
  22. }