aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorEd Maste <emaste@FreeBSD.org>2011-10-24 18:29:50 +0000
committerEd Maste <emaste@FreeBSD.org>2011-10-24 18:29:50 +0000
commit6f8193d2c489c7ac78f0b1e149de2aa281821553 (patch)
treebf9aea0fdbe10d9b1fa034f9b3b32e56f1930838 /usr.sbin
parent8c094ecc832ba7cecea616ca5d5314fd443e2b65 (diff)
downloadsrc-6f8193d2c489c7ac78f0b1e149de2aa281821553.tar.gz
src-6f8193d2c489c7ac78f0b1e149de2aa281821553.zip
Avoid printing // for packages that install to /
I have some packages that install to / (for whatever reason). Right now we print entries of the form //path/to/file when listing files (pkg_info -L, pkg_info -g etc.) This change avoids printing the redundant / .
Notes
Notes: svn path=/head/; revision=226697
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_install/info/show.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/usr.sbin/pkg_install/info/show.c b/usr.sbin/pkg_install/info/show.c
index c65c312a5062..8a05dd2c2c38 100644
--- a/usr.sbin/pkg_install/info/show.c
+++ b/usr.sbin/pkg_install/info/show.c
@@ -207,6 +207,14 @@ show_plist(const char *title, Package *plist, plist_t type, Boolean showall)
}
}
+const char *
+elide_root(const char *dir)
+{
+ if (strcmp(dir, "/") == 0)
+ return "";
+ return dir;
+}
+
/* Show all files in the packing list (except ignored ones) */
void
show_files(const char *title, Package *plist)
@@ -223,7 +231,7 @@ show_files(const char *title, Package *plist)
switch(p->type) {
case PLIST_FILE:
if (!ign)
- printf("%s/%s\n", dir, p->name);
+ printf("%s/%s\n", elide_root(dir), p->name);
ign = FALSE;
break;
@@ -270,7 +278,7 @@ show_size(const char *title, Package *plist)
switch (p->type) {
case PLIST_FILE:
if (!ign) {
- snprintf(tmp, FILENAME_MAX, "%s/%s", dir, p->name);
+ snprintf(tmp, FILENAME_MAX, "%s/%s", elide_root(dir), p->name);
if (!lstat(tmp, &sb)) {
size += sb.st_size;
if (Verbose)
@@ -328,7 +336,7 @@ show_cksum(const char *title, Package *plist)
else
dir = p->name;
} else if (p->type == PLIST_FILE) {
- snprintf(tmp, FILENAME_MAX, "%s/%s", dir, p->name);
+ snprintf(tmp, FILENAME_MAX, "%s/%s", elide_root(dir), p->name);
if (!fexists(tmp))
warnx("%s doesn't exist", tmp);
else if (p->next && p->next->type == PLIST_COMMENT &&