[hackers] [sbase] tar: support -f - for stdin/out || Eivind Uggedal

From: <git_AT_suckless.org>
Date: Mon, 15 Feb 2016 11:20:21 +0100 (CET)

commit e13f571d119cdd6fedef3f748a264bb143cecc70
Author: Eivind Uggedal <eivind_AT_uggedal.com>
AuthorDate: Mon Feb 15 09:48:32 2016 +0000
Commit: sin <sin_AT_2f30.org>
CommitDate: Mon Feb 15 10:20:12 2016 +0000

    tar: support -f - for stdin/out

diff --git a/tar.1 b/tar.1
index 8394fdb..7cc34b4 100644
--- a/tar.1
+++ b/tar.1
_AT_@ -32,7 +32,8 @@ before beginning.
 .It Fl f Ar file
 Set
 .Ar file
-as input | output archive instead of stdin | stdout.
+as input | output archive instead of stdin | stdout. If '-',
+stdin | stdout is used.
 .It Fl m
 Do not preserve modification time.
 .It Fl t
diff --git a/tar.c b/tar.c
index b4ba2d6..10b2024 100644
--- a/tar.c
+++ b/tar.c
_AT_@ -550,7 +550,7 @@ main(int argc, char *argv[])
         switch (mode) {
         case 'c':
                 tarfd = 1;
- if (file) {
+ if (file && *file != '-') {
                         tarfd = open(file, O_WRONLY | O_TRUNC | O_CREAT, 0644);
                         if (tarfd < 0)
                                 eprintf("open %s:", file);
_AT_@ -571,7 +571,7 @@ main(int argc, char *argv[])
         case 't':
         case 'x':
                 tarfd = 0;
- if (file) {
+ if (file && *file != '-') {
                         tarfd = open(file, O_RDONLY);
                         if (tarfd < 0)
                                 eprintf("open %s:", file);
Received on Mon Feb 15 2016 - 11:20:21 CET

This archive was generated by hypermail 2.3.0 : Mon Feb 15 2016 - 11:24:28 CET