From be66c5b741c8bb0dfc35a4313478b86a45c973c1 Mon Sep 17 00:00:00 2001 From: DTB Date: Wed, 10 Jan 2024 15:00:57 -0700 Subject: [PATCH] interpret "-" as stdin/stdout --- dj/dj.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/dj/dj.c b/dj/dj.c index e407500..db847bd 100644 --- a/dj/dj.c +++ b/dj/dj.c @@ -314,7 +314,12 @@ int main(int argc, char *argv[]){ while((c = getopt(argc, argv, "a:Ab:B:c:di:fhHqs:S:o:")) != -1) switch(c){ case 'i': case 'o': - if(Io_fdopen(&ep[c == 'o'], optarg) != -1) + i = (c == 'o'); + if(optarg[0] == '-' && optarg[1] == '\0'){ /* optarg == "-" */ + ep[i].fd = (i == 0) ? STDIN_FILENO : STDOUT_FILENO; + ep[i].fn = (i == 0) ? stdin_name : stdout_name; + break; + }else if(Io_fdopen(&ep[i], optarg) != -1) break; terminate(ep); return oserr(optarg);