Control: tag -1 patch

Hi,

please find attached a simple patch which enables this functionality by
assigning STDIN_FILENO to the file descriptor instead of trying to open it if
the filename is equal to "-".

The tricky part is, that the archive filename is not an argument to the
--ctrl-tarfile or --fsys-tarfile argument as it could be interpreted from the
dpkg-deb man page. Instead, the archive filename is a positional argument and
since there can be no positional argument starting with a minus character, it
must be given after a "--" like this:

dpkg-deb --ctrl-tarfile -- -

I added a note about this into the man page.

Thanks!

cheers, josch
diff --git a/dpkg-deb/extract.c b/dpkg-deb/extract.c
index 2c92940..00683f9 100644
--- a/dpkg-deb/extract.c
+++ b/dpkg-deb/extract.c
@@ -124,7 +124,10 @@ extracthalf(const char *debar, const char *dir,
   bool header_done;
   enum compressor_type decompressor = COMPRESSOR_TYPE_GZIP;
 
-  arfd = open(debar, O_RDONLY);
+  if (strcmp(debar, "-") == 0)
+    arfd = STDIN_FILENO;
+  else
+    arfd = open(debar, O_RDONLY);
   if (arfd < 0)
     ohshite(_("failed to read archive `%.255s'"), debar);
   if (fstat(arfd, &stab))
diff --git a/man/dpkg-deb.1 b/man/dpkg-deb.1
index c5038ec..9fa2aea 100644
--- a/man/dpkg-deb.1
+++ b/man/dpkg-deb.1
@@ -43,6 +43,12 @@ with whatever options you want to pass to
 will spot that you wanted
 .B dpkg\-deb
 and run it for you.
+.PP
+.B dpkg\-deb
+can also read the archive from standard input if the archive name is given as
+single minus character. Note, that this argument must be interpreted as a
+positional argument and must thus be specified after a separating "\-\-"
+(without the quotes).
 .
 .SH COMMANDS
 .TP

Reply via email to