Rob Landley | 2896480 | 2008-01-19 17:08:39 -0600 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: |
| 2 | * |
Rob Landley | f2311a4 | 2006-11-04 17:45:18 -0500 | [diff] [blame] | 3 | * pwd.c - Print working directory. |
Rob Landley | 2896480 | 2008-01-19 17:08:39 -0600 | [diff] [blame] | 4 | * |
| 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 Landley | 55928b1 | 2008-01-19 17:43:27 -0600 | [diff] [blame] | 11 | USE_PWD(NEWTOY(pwd, NULL, TOYFLAG_BIN)) |
| 12 | |
Rob Landley | 2896480 | 2008-01-19 17:08:39 -0600 | [diff] [blame] | 13 | config 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 Landley | f2311a4 | 2006-11-04 17:45:18 -0500 | [diff] [blame] | 21 | |
| 22 | #include "toys.h" |
| 23 | |
Rob Landley | efda21c | 2007-11-29 18:14:37 -0600 | [diff] [blame] | 24 | void pwd_main(void) |
Rob Landley | f2311a4 | 2006-11-04 17:45:18 -0500 | [diff] [blame] | 25 | { |
| 26 | char *pwd = xgetcwd(); |
| 27 | |
Rob Landley | a4f7988 | 2007-01-20 22:59:00 -0500 | [diff] [blame] | 28 | xprintf("%s\n", pwd); |
Rob Landley | de05a70 | 2007-01-31 14:37:01 -0500 | [diff] [blame] | 29 | if (CFG_TOYBOX_FREE) free(pwd); |
Rob Landley | f2311a4 | 2006-11-04 17:45:18 -0500 | [diff] [blame] | 30 | } |