From a0bb92c9f397eb69914be03d7de16ae8e83e7426 Mon Sep 17 00:00:00 2001 From: "m@mmmmarascio.xyz" Date: Mon, 1 Aug 2016 11:25:57 +0200 Subject: [PATCH] Enable inc(1) to read from stdin The -file switch handles the argument "-" special and reads from stdin in this case. --- man/inc.man1 | 7 +++++ test/tests/inc/test-read-stdin | 66 ++++++++++++++++++++++++++++++++++++++++ uip/inc.c | 49 +++++++++++++++-------------- 3 files changed, 100 insertions(+), 22 deletions(-) create mode 100644 test/tests/inc/test-read-stdin diff --git a/man/inc.man1 b/man/inc.man1 index 817c1bd..ed586c1 100644 --- a/man/inc.man1 +++ b/man/inc.man1 @@ -124,6 +124,13 @@ By using the switch, one can direct .B inc to incorporate messages from a file other than the user's maildrop. +In particular, if +.I name +is +.RI ` - ' +then +.B inc +will read messages from standard input. Note that the named file will NOT be zeroed, unless the .B \-truncate switch is given. diff --git a/test/tests/inc/test-read-stdin b/test/tests/inc/test-read-stdin new file mode 100644 index 0000000..d771d32 --- /dev/null +++ b/test/tests/inc/test-read-stdin @@ -0,0 +1,66 @@ +#!/bin/sh +########################################################## +# Test incorporating mail from stdin with `inc -file -`. # +########################################################## +. "$MH_TEST_COMMON" + +# Test empty stdin from a pipe. +runandcheck "printf '' |inc -file -" <$f && inc -file - <$f" <$f && inc -file - <$f" <