---
 .gitignore |  1 +
 Makefile   |  1 +
 realpath.c | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+)
 create mode 100644 realpath.c

diff --git a/.gitignore b/.gitignore
index e789e24..f1ce1c2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -57,6 +57,7 @@
 /printf
 /pwd
 /readlink
+/realpath
 /renice
 /rev
 /rm
diff --git a/Makefile b/Makefile
index 8e8732a..f0657d3 100644
--- a/Makefile
+++ b/Makefile
@@ -147,6 +147,7 @@ BIN =\
        printf\
        pwd\
        readlink\
+       realpath\
        renice\
        rev\
        rm\
diff --git a/realpath.c b/realpath.c
new file mode 100644
index 0000000..c6d6204
--- /dev/null
+++ b/realpath.c
@@ -0,0 +1,34 @@
+#include <limits.h>
+#include <stdlib.h>
+#include <stdio.h>
+
+#include "util.h"
+
+static void
+usage(void)
+{
+       eprintf("usage: %s file ...\n", argv0);
+}
+
+int
+main(int argc, char *argv[])
+{
+       char buf[PATH_MAX];
+       size_t i;
+
+       ARGBEGIN {
+       default:
+               usage();
+       } ARGEND
+
+       if (argc == 0)
+               usage();
+       for (i = 0; i < argc; i++) {
+               if (realpath(argv[i], buf) == NULL)
+                       eprintf("realpath:");
+               puts(buf);
+       }
+
+       return fshut(stdout, "<stdout>");
+
+}
-- 
2.44.0


Reply via email to