aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/kiss-readlink.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/bin/kiss-readlink.c b/bin/kiss-readlink.c
index 04426f0..279e1b9 100644
--- a/bin/kiss-readlink.c
+++ b/bin/kiss-readlink.c
@@ -4,11 +4,15 @@
// This is basically a 'readlink -f' command.
#include <stdio.h>
#include <stdlib.h>
+#include <libgen.h>
#include <string.h>
int main(int argc, char *argv[]) {
char buf[512];
+ char bname[512];
+ strcpy(bname, "/");
+ strcat(bname, (basename(argv[1])));
if (argc != 2 || strcmp(argv[1], "--help") == 0) {
printf("usage: %s <file>\n", argv[0]);
@@ -16,8 +20,12 @@ int main(int argc, char *argv[]) {
}
if (!realpath(argv[1], buf)) {
+
+ if (!realpath(dirname(argv[1]), buf)) {
perror("realpath");
return(1);
+ }
+ strcat(buf, bname);
}
printf("%s\n", buf);