"dpkg --listfiles" and blank lines
dpkg --listfiles puts a blank line after the list of packages from
each file. This is irritating if you're trying to use the output as a
list of files for some kind of processing in a script, as you have to
special-case the blank line.
The patch below adds an option to suppress this blank line. The
default behaviour is unchanged.
ttfn/rjk
diff -x TAGS -x *.pot -x *~ -ru dpkg-1.8.3.1.old/debian/changelog dpkg-1.8.3.1/debian/changelog
--- dpkg-1.8.3.1.old/debian/changelog Sat Jan 13 13:52:35 2001
+++ dpkg-1.8.3.1/debian/changelog Sun Mar 11 11:52:39 2001
@@ -1,3 +1,13 @@
+dpkg (1.8.3.1.rjk-20010311) unstable; urgency=low
+
+ * Add --no-blank-lines option to dpkg to eliminate trailing blank lines from
+ --listfiles output. Each package enquiry now needs to decide for
+ itself whether to output the blank line or not; currently only
+ --listfiles has an output format where it makes any sense to ever not
+ do so.
+
+ -- Richard Kettlewell <rjk@greenend.org.uk> Sun, 11 Mar 2001 11:31:22 +0000
+
dpkg (1.8.3.1) unstable; urgency=low
* Revert change to nfmalloc.c that was causing SIGBUS on sparc.
diff -x TAGS -x *.pot -x *~ -ru dpkg-1.8.3.1.old/main/dpkg.8 dpkg-1.8.3.1/main/dpkg.8
--- dpkg-1.8.3.1.old/main/dpkg.8 Fri Jan 12 13:55:59 2001
+++ dpkg-1.8.3.1/main/dpkg.8 Sun Mar 11 11:43:37 2001
@@ -452,6 +452,10 @@
.BR -E " | " --skip-same-version
Don't install the package if the same version of the package is already
installed.
+.TP
+.B --no-blank-line
+Suppress the blank line after the output for each package from
+.BR --listfiles .
.SH FILES
The files listed here are in their default directories, see option
diff -x TAGS -x *.pot -x *~ -ru dpkg-1.8.3.1.old/main/enquiry.c dpkg-1.8.3.1/main/enquiry.c
--- dpkg-1.8.3.1.old/main/enquiry.c Fri Jan 12 16:02:12 2001
+++ dpkg-1.8.3.1/main/enquiry.c Sun Mar 11 11:49:32 2001
@@ -451,6 +451,7 @@
} else {
writerecord(stdout, "<stdout>", pkg, &pkg->installed);
}
+ putchar('\n');
break;
case act_printavail:
@@ -460,6 +461,7 @@
} else {
writerecord(stdout, "<stdout>", pkg, &pkg->available);
}
+ putchar('\n');
break;
case act_listfiles:
@@ -488,6 +490,7 @@
file= file->next;
}
}
+ if(f_blankline) putchar('\n');
break;
}
break;
@@ -495,8 +498,7 @@
default:
internerr("unknown action");
}
-
- putchar('\n');
+
if (ferror(stdout)) werr("stdout");
}
diff -x TAGS -x *.pot -x *~ -ru dpkg-1.8.3.1.old/main/main.c dpkg-1.8.3.1/main/main.c
--- dpkg-1.8.3.1.old/main/main.c Fri Jan 12 16:02:12 2001
+++ dpkg-1.8.3.1/main/main.c Sun Mar 11 11:44:11 2001
@@ -103,6 +103,7 @@
--force-... Override problems - see --force-help\n\
--no-force-...|--refuse-... Stop when problems encountered\n\
--abort-after <n> Abort after encountering <n> errors\n\
+ --no-blank-line Eliminate blank lines from --listfiles\n\
\n\
Comparison operators for --compare-versions are:\n\
lt le eq ne ge gt (treat no version as earlier than any version);\n\
@@ -127,7 +128,7 @@
const struct cmdinfo *cipaction= 0;
int f_pending=0, f_recursive=0, f_alsoselect=1, f_skipsame=0, f_noact=0;
-int f_autodeconf=0, f_largemem=0;
+int f_autodeconf=0, f_largemem=0, f_blankline=1;
unsigned long f_debug=0;
/* Change fc_overwrite to 1 to enable force-overwrite by default */
int fc_downgrade=1, fc_configureany=0, fc_hold=0, fc_removereinstreq=0, fc_overwrite=0;
@@ -351,6 +352,7 @@
ACTION( "predep-package", 0, act_predeppackage, predeppackage ),
ACTION( "compare-versions", 0, act_cmpversions, cmpversions ),
+ { "no-blank-line", 0, 0, &f_blankline, 0, 0, 0 },
{ "pending", 'a', 0, &f_pending, 0, 0, 1 },
{ "recursive", 'R', 0, &f_recursive, 0, 0, 1 },
{ "no-act", 0, 0, &f_noact, 0, 0, 1 },
diff -x TAGS -x *.pot -x *~ -ru dpkg-1.8.3.1.old/main/main.h dpkg-1.8.3.1/main/main.h
--- dpkg-1.8.3.1.old/main/main.h Sun Nov 5 14:58:50 2000
+++ dpkg-1.8.3.1/main/main.h Sun Mar 11 11:38:20 2001
@@ -78,7 +78,7 @@
extern const struct cmdinfo *cipaction;
extern int f_pending, f_recursive, f_alsoselect, f_skipsame, f_noact;
-extern int f_autodeconf, f_largemem;
+extern int f_autodeconf, f_largemem, f_blankline;
extern unsigned long f_debug;
extern int fc_downgrade, fc_configureany, fc_hold, fc_removereinstreq, fc_overwrite;
extern int fc_removeessential, fc_conflicts, fc_depends, fc_dependsversion;
Reply to: