aboutsummaryrefslogtreecommitdiff
path: root/toys
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2007-04-29 19:55:21 -0400
committerRob Landley <rob@landley.net>2007-04-29 19:55:21 -0400
commit0c93f6c7ab7aab56b39793a2317a9bff16b8ae04 (patch)
tree275dcaf29f05b6f15cf87327746d6e3c3d07e5ac /toys
parentc92fde0bc75ade9d06c0d843c4693b9e2e338938 (diff)
downloadtoybox-0c93f6c7ab7aab56b39793a2317a9bff16b8ae04.tar.gz
Add readlink, xreadlink(), and change xrealloc() to not fight the stupid
compiler so much.
Diffstat (limited to 'toys')
-rw-r--r--toys/Config.in16
-rw-r--r--toys/toylist.h1
-rw-r--r--toys/toysh.c2
3 files changed, 18 insertions, 1 deletions
diff --git a/toys/Config.in b/toys/Config.in
index 5634436c..5aae5c54 100644
--- a/toys/Config.in
+++ b/toys/Config.in
@@ -194,6 +194,22 @@ config PWD
The print working directory command prints the current directory.
+config READLINK
+ bool "readlink"
+ default n
+ help
+ usage: readlink
+
+ Show what a symbolic link points to.
+
+config READLINK_FINAL
+ bool "readlink -f"
+ default n
+ help
+ usage: readlink [-f]
+
+ -f Show final location, including normal files and multiple symlinks.
+
config SYNC
bool "sync"
default n
diff --git a/toys/toylist.h b/toys/toylist.h
index d686877c..125b0376 100644
--- a/toys/toylist.h
+++ b/toys/toylist.h
@@ -94,6 +94,7 @@ USE_HELLO(NEWTOY(hello, NULL, TOYFLAG_USR))
USE_MKE2FS(NEWTOY(mke2fs, MKE2FS_OPTSTRING, TOYFLAG_SBIN))
USE_ONEIT(NEWTOY(oneit, "+<1p", TOYFLAG_SBIN))
USE_PWD(NEWTOY(pwd, NULL, TOYFLAG_BIN))
+USE_READLINK(NEWTOY(readlink, "<1f", TOYFLAG_BIN))
USE_TOYSH(OLDTOY(sh, toysh, "c:i", TOYFLAG_BIN))
USE_SYNC(NEWTOY(sync, NULL, TOYFLAG_BIN))
USE_TOUCH(NEWTOY(touch, "l#t:r:mca", TOYFLAG_BIN))
diff --git a/toys/toysh.c b/toys/toysh.c
index c383b89a..ef061bde 100644
--- a/toys/toysh.c
+++ b/toys/toysh.c
@@ -61,7 +61,7 @@ static char *parse_word(char *start, struct command **cmd)
// Allocate more space if there's no room for NULL terminator.
if (!((*cmd)->argc & 7))
- xrealloc((void **)cmd,
+ *cmd=xrealloc(*cmd,
sizeof(struct command) + ((*cmd)->argc+8)*sizeof(char *));
(*cmd)->argv[(*cmd)->argc] = 0;
return end;