aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/ln.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2013-01-05 00:44:24 -0600
committerRob Landley <rob@landley.net>2013-01-05 00:44:24 -0600
commit41ed9793498916c63d375326ea8c9b3fa1479dd6 (patch)
tree85cbe885f586ac1c0402b3bf3b3b3e7f7afa618b /toys/posix/ln.c
parent90e8605ea587c4ebd00de77e3c71551b6e26b7c0 (diff)
downloadtoybox-41ed9793498916c63d375326ea8c9b3fa1479dd6.tar.gz
Use basename() where appropriate.
Diffstat (limited to 'toys/posix/ln.c')
-rw-r--r--toys/posix/ln.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/toys/posix/ln.c b/toys/posix/ln.c
index fea6fff2..d69aabf4 100644
--- a/toys/posix/ln.c
+++ b/toys/posix/ln.c
@@ -47,11 +47,8 @@ void ln_main(void)
int rc;
char *try = toys.optargs[i];
- if (S_ISDIR(buf.st_mode)) {
- new = strrchr(try, '/');
- if (!new) new = try;
- new = xmsprintf("%s/%s", dest, new);
- } else new = dest;
+ if (S_ISDIR(buf.st_mode)) new = xmsprintf("%s/%s", dest, basename(try));
+ else new = dest;
/* Silently unlink the existing target. If it doesn't exist,
* then we just move on */
if (toys.optflags & FLAG_f) unlink(new);