fish: Fix 'copy-out' command when local directory is "/foo".
authorRichard Jones <rjones@redhat.com>
Fri, 10 Sep 2010 09:27:45 +0000 (10:27 +0100)
committerRichard Jones <rjones@redhat.com>
Fri, 10 Sep 2010 09:27:45 +0000 (10:27 +0100)
fish/copy.c

index 789e430..944f4cc 100644 (file)
@@ -148,11 +148,14 @@ split_path (char *buf, size_t buf_size,
   }
 
   char *p = strrchr (buf, '/');
   }
 
   char *p = strrchr (buf, '/');
-  if (p && p > buf) {
+  if (p && p > buf) {           /* "foo/bar" */
     *p = '\0';
     p++;
     if (dirname) *dirname = buf;
     if (basename) *basename = p;
     *p = '\0';
     p++;
     if (dirname) *dirname = buf;
     if (basename) *basename = p;
+  } else if (p && p == buf) {   /* "/foo" */
+    if (dirname) *dirname = bad_cast ("/");
+    if (basename) *basename = buf+1;
   } else {
     if (dirname) *dirname = NULL;
     if (basename) *basename = buf;
   } else {
     if (dirname) *dirname = NULL;
     if (basename) *basename = buf;