Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Jun 2023 19:28:02 GMT
From:      =?utf-8?Q?Dag-Erling=20Sm=C3=B8rgrav?= <des@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: f08f90e69877 - main - asa: Read from stdin if *argv is "-".
Message-ID:  <202306151928.35FJS2JE065385@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by des:

URL: https://cgit.FreeBSD.org/src/commit/?id=f08f90e6987775f88d25efbd8762c361819f40ba

commit f08f90e6987775f88d25efbd8762c361819f40ba
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2023-06-15 19:23:22 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2023-06-15 19:24:58 +0000

    asa: Read from stdin if *argv is "-".
    
    MFC after:      1 week
    Sponsored by:   Klara, Inc.
    Reviewed by:    markj
    Differential Revision:  https://reviews.freebsd.org/D40563
---
 usr.bin/asa/asa.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/usr.bin/asa/asa.c b/usr.bin/asa/asa.c
index 11438b607466..a6c3d7d7c1e5 100644
--- a/usr.bin/asa/asa.c
+++ b/usr.bin/asa/asa.c
@@ -43,6 +43,7 @@ __FBSDID("$FreeBSD$");
 #include <err.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <string.h>
 #include <unistd.h>
 
 static void asa(FILE *);
@@ -71,13 +72,17 @@ main(int argc, char *argv[])
 		asa(stdin);
 	else {
 		while ((fn = *argv++) != NULL) {
-                        if ((fp = fopen(fn, "r")) == NULL) {
-				warn("%s", fn);
-				exval = 1;
-				continue;
-                        }
-			asa(fp);
-			fclose(fp);
+			if (strcmp(fn, "-") == 0) {
+				asa(stdin);
+			} else {
+				if ((fp = fopen(fn, "r")) == NULL) {
+					warn("%s", fn);
+					exval = 1;
+					continue;
+				}
+				asa(fp);
+				fclose(fp);
+			}
 		}
 	}
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202306151928.35FJS2JE065385>