tOptionally accept input from a command (eg. fmt(1)) - scribo - Email-based phlog generator
(HTM) git clone git://git.z3bra.org/scribo.git
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 866b5fcbd5aa5bdd3ea2fecdf3b568be1631ecf0
(DIR) parent 2be2aca8183d21409e11f0662fe5ce761adeb89a
(HTM) Author: Willy Goiffon <dev@z3bra.org>
Date: Wed, 9 Sep 2020 09:15:53 +0200
Optionally accept input from a command (eg. fmt(1))
Diffstat:
M scribo.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
---
(DIR) diff --git a/scribo.c b/scribo.c
t@@ -47,7 +47,7 @@ int writeindex(FILE *, char *);
void
usage(char *pgm)
{
- fprintf(stderr, "usage: %s [-a author] [-b basedir] [-d fmt] [-io file]\n", pgm);
+ fprintf(stderr, "usage: %s [-a author] [-b basedir] [-d fmt] [-io file] [-x cmd]\n", pgm);
}
char *
t@@ -273,7 +273,7 @@ int
main(int argc, char *argv[])
{
FILE *in = stdin, *out = stdout;
- char *argv0, *infile, *outfile;
+ char *argv0, *cmd, *infile, *outfile;
struct headers headers;
infile = NULL;
t@@ -295,6 +295,9 @@ main(int argc, char *argv[])
case 'o':
outfile = EARGF(usage(argv0));
break;
+ case 'x':
+ cmd = EARGF(usage(argv0));
+ break;
default:
usage(argv0);
exit(1);
t@@ -302,6 +305,8 @@ main(int argc, char *argv[])
if (infile && strcmp(infile, "-"))
in = fopen(infile, "r");
+ else if (cmd)
+ in = popen(cmd, "r");
if (!in) {
perror(infile);