aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2007-06-18 00:15:48 -0400
committerRob Landley <rob@landley.net>2007-06-18 00:15:48 -0400
commit5288145aa65813308c52e56714bea7728bcd4175 (patch)
tree40c7628ef7958251e7901ddb13cf6ebefc659ac1
parent5084feadff6503852bf11019baa3e943bbcd4305 (diff)
downloadtoybox-5288145aa65813308c52e56714bea7728bcd4175.tar.gz
Add readlink. Why doesn't mercurial show newly added files in "hg diff"?
-rw-r--r--toys/readlink.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/toys/readlink.c b/toys/readlink.c
new file mode 100644
index 00000000..25dc7ba1
--- /dev/null
+++ b/toys/readlink.c
@@ -0,0 +1,20 @@
+/* vi: set sw=4 ts=4: */
+/*
+ * readlink.c - Return string representation of a symbolic link.
+ */
+// Note: Hardware in LINK_MAX as 127 since it was removed from glibc.
+
+#include "toys.h"
+
+int readlink_main(void)
+{
+ char *s = xreadlink(*toys.optargs);
+
+ if (s) {
+ xputs(s);
+ if (CFG_TOYBOX_FREE) free(s);
+ return 0;
+ }
+
+ return 1;
+}