blob: 9279dbee627b90c0eb9165c45ab20e1d522c00ce [file] [log] [blame]
Erik Andersene49d5ec2000-02-08 19:58:47 +00001/* vi: set sw=4 ts=4: */
Eric Andersenc4996011999-10-20 22:08:37 +00002/*
3 * Mini pwd implementation for busybox
4 *
Eric Andersenc4996011999-10-20 22:08:37 +00005 * Copyright (C) 1995, 1996 by Bruce Perens <bruce@pixar.com>.
6 *
"Robert P. J. Day"801ab142006-07-12 07:56:04 +00007 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
Eric Andersenc4996011999-10-20 22:08:37 +00008 */
9
Denis Vlasenkob6adbf12007-05-26 19:00:18 +000010#include "libbb.h"
Eric Andersencc8ed391999-10-05 16:24:54 +000011
Denis Vlasenko99912ca2007-04-10 15:43:37 +000012/* This is a NOFORK applet. Be very careful! */
13
Denis Vlasenko9b49a5e2007-10-11 10:05:36 +000014int pwd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
Denis Vlasenko68404f12008-03-17 09:00:54 +000015int pwd_main(int argc ATTRIBUTE_UNUSED, char **argv ATTRIBUTE_UNUSED)
Eric Andersencc8ed391999-10-05 16:24:54 +000016{
Manuel Novoa III cad53642003-03-19 09:13:01 +000017 char *buf;
18
Denis Vlasenko6ca04442007-02-11 16:19:28 +000019 buf = xrealloc_getcwd_or_warn(NULL);
20 if (buf != NULL) {
Eric Andersene5dfced2001-04-09 22:48:12 +000021 puts(buf);
Denis Vlasenko99912ca2007-04-10 15:43:37 +000022 free(buf);
23 return fflush(stdout);
Eric Andersene5dfced2001-04-09 22:48:12 +000024 }
Manuel Novoa III cad53642003-03-19 09:13:01 +000025
Eric Andersene5dfced2001-04-09 22:48:12 +000026 return EXIT_FAILURE;
Eric Andersencc8ed391999-10-05 16:24:54 +000027}