blob: d84c504a2e6543b8a3f268f3a9f42b72bbad84fa [file] [log] [blame]
Rob Landley28964802008-01-19 17:08:39 -06001/* vi: set sw=4 ts=4:
2 *
Rob Landleyf2311a42006-11-04 17:45:18 -05003 * pwd.c - Print working directory.
Rob Landley28964802008-01-19 17:08:39 -06004 *
5 * Copyright 2006 Rob Landley <rob@landley.net>
6 *
7 * See http://www.opengroup.org/onlinepubs/009695399/utilities/echo.html
8 *
9 * TODO: add -L -P
10
Rob Landley55928b12008-01-19 17:43:27 -060011USE_PWD(NEWTOY(pwd, NULL, TOYFLAG_BIN))
12
Rob Landley28964802008-01-19 17:08:39 -060013config PWD
14 bool "pwd"
15 default y
16 help
17 usage: pwd
18
19 The print working directory command prints the current directory.
20*/
Rob Landleyf2311a42006-11-04 17:45:18 -050021
22#include "toys.h"
23
Rob Landleyefda21c2007-11-29 18:14:37 -060024void pwd_main(void)
Rob Landleyf2311a42006-11-04 17:45:18 -050025{
26 char *pwd = xgetcwd();
27
Rob Landleya4f79882007-01-20 22:59:00 -050028 xprintf("%s\n", pwd);
Rob Landleyde05a702007-01-31 14:37:01 -050029 if (CFG_TOYBOX_FREE) free(pwd);
Rob Landleyf2311a42006-11-04 17:45:18 -050030}