--- tar.1 | 4 +++- tar.c | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/tar.1 b/tar.1 index 6341e17da4d0..ff6578b56d5c 100644 --- a/tar.1 +++ b/tar.1 _AT_@ -32,7 +32,9 @@ 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. The - +.Ar file +is interpreted as stdin | stdout. .It Fl m Do not preserve modification time. .It Fl t diff --git a/tar.c b/tar.c index 8dbce22cc501..d8ab0db608f5 100644 --- a/tar.c +++ b/tar.c _AT_@ -541,12 +541,13 @@ main(int argc, char *argv[]) switch (mode) { case 'c': tarfd = 1; - if (file) { - tarfd = open(file, O_WRONLY | O_TRUNC | O_CREAT, 0644); - if (tarfd < 0) - eprintf("open %s:", file); - if (lstat(file, &st) < 0) - eprintf("lstat %s:", file); + if (!file || (file[0] == '-' && !file[1])) { + tarfd = 1; + } else if ((tarfd = open(file, O_WRONLY | O_TRUNC | O_CREAT, 0644)) < 0) { + eprintf("open %s:", file); + } else if (lstat(file, &st) < 0) { + eprintf("lstat %s:", file); + } else { tarinode = st.st_ino; tardev = st.st_dev; } _AT_@ -561,11 +562,10 @@ main(int argc, char *argv[]) break; case 't': case 'x': - tarfd = 0; - if (file) { - tarfd = open(file, O_RDONLY); - if (tarfd < 0) - eprintf("open %s:", file); + if (!file || (file[0] == '-' && !file[1])) { + tarfd = 0; + } else if ((tarfd = open(file, O_RDONLY)) < 0) { + eprintf("open %s:", file); } if (filtertool) { -- 2.4.0Received on Tue May 12 2015 - 15:57:11 CEST
This archive was generated by hypermail 2.3.0 : Tue May 12 2015 - 16:00:12 CEST