summaryrefslogtreecommitdiffstats
path: root/fish/copy.c
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2010-09-10 10:27:45 +0100
committerRichard Jones <rjones@redhat.com>2010-09-10 10:27:45 +0100
commit878c8c77d8b46b1c4dd5189f67f0262d44eed70c (patch)
treeb71a3c3a3d9d7b4751e678f8b68fcee1e3142256 /fish/copy.c
parent3578f170a1f70a86fb2213fc576190ad5aff61be (diff)
downloadlibguestfs-878c8c77d8b46b1c4dd5189f67f0262d44eed70c.tar.gz
libguestfs-878c8c77d8b46b1c4dd5189f67f0262d44eed70c.tar.xz
libguestfs-878c8c77d8b46b1c4dd5189f67f0262d44eed70c.zip
fish: Fix 'copy-out' command when local directory is "/foo".
Diffstat (limited to 'fish/copy.c')
-rw-r--r--fish/copy.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/fish/copy.c b/fish/copy.c
index 789e430d..944f4ccb 100644
--- a/fish/copy.c
+++ b/fish/copy.c
@@ -148,11 +148,14 @@ split_path (char *buf, size_t buf_size,
}
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;
+ } 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;