summaryrefslogtreecommitdiff
path: root/basename.c
diff options
context:
space:
mode:
Diffstat (limited to 'basename.c')
-rw-r--r--basename.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/basename.c b/basename.c
index 06e2766..5fe5e0f 100644
--- a/basename.c
+++ b/basename.c
@@ -34,8 +34,10 @@ extern int basename_main(int argc, char **argv)
argv++;
s1=*argv+strlen(*argv)-1;
- if (*s1 == '/')
+ while (s1 && *s1 == '/') {
*s1 = '\0';
+ s1=*argv+strlen(*argv)-1;
+ }
s = strrchr(*argv, '/');
printf("%s\n", (s)? s + 1 : *argv);
exit(TRUE);