blob: 2949c55c24aabf4c7810b85e907d97240fb717ca [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 *
Denys Vlasenko0ef64bd2010-08-16 20:14:46 +02007 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
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);
Denys Vlasenko8131eea2009-11-02 14:19:51 +010023 return fflush_all();
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}