blob: 57953d246dd24d2e3191118750a5697f377c5be7 [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 Vlasenkoa60f84e2008-07-05 09:18:54 +000015int pwd_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
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}