summaryrefslogtreecommitdiff
path: root/src/ln.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1993-05-22 02:09:05 +0000
committerJim Meyering <jim@meyering.net>1993-05-22 02:09:05 +0000
commitd1c5cbfcddaced8d64b23bc3f22bfc4082b58604 (patch)
tree684956921106115248c1a6e3263fba4309b0d698 /src/ln.c
parent5ca6750d57a9d89163cd3548758589d4ab14c75c (diff)
downloadcoreutils-d1c5cbfcddaced8d64b23bc3f22bfc4082b58604.tar.gz
coreutils-d1c5cbfcddaced8d64b23bc3f22bfc4082b58604.tar.bz2
coreutils-d1c5cbfcddaced8d64b23bc3f22bfc4082b58604.zip
merge with 3.5.5
Diffstat (limited to 'src/ln.c')
-rw-r--r--src/ln.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/ln.c b/src/ln.c
index f9cb92ace..6981e22ed 100644
--- a/src/ln.c
+++ b/src/ln.c
@@ -38,6 +38,7 @@ enum backup_type get_version ();
int isdir ();
int yesno ();
void error ();
+void strip_trailing_slashes ();
static void usage ();
static int do_link ();
@@ -150,7 +151,10 @@ main (argc, argv)
}
if (flag_version)
- fprintf (stderr, "%s\n", version_string);
+ {
+ fprintf (stderr, "%s\n", version_string);
+ exit (0);
+ }
if (flag_help)
usage ();
@@ -212,8 +216,13 @@ do_link (source, dest)
/* Target is a directory; build the full filename. */
char *new_dest;
char *source_base;
+ char *tmp_source;
+
+ tmp_source = (char *) alloca (strlen (source) + 1);
+ strcpy (tmp_source, source);
+ strip_trailing_slashes (tmp_source);
- source_base = basename (source);
+ source_base = basename (tmp_source);
new_dest = (char *)
alloca (strlen (source_base) + 1 + strlen (dest) + 1);
sprintf (new_dest, "%s/%s", dest, source_base);