summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjsg <jsg@openbsd.org>2013-06-21 06:49:42 +0000
committerjsg <jsg@openbsd.org>2013-06-21 06:49:42 +0000
commit0595370d24ff236dbe6081edaf7c4351bbfccd48 (patch)
tree8db9518a444af546902d59c77500846d0a0dc0af
parentAdd earlysig test to check whether the pthread fork() wrapper (diff)
downloadwireguard-openbsd-0595370d24ff236dbe6081edaf7c4351bbfccd48.tar.xz
wireguard-openbsd-0595370d24ff236dbe6081edaf7c4351bbfccd48.zip
Default to stdin/stdout if no input files are
given to indent. Based on FreeBSD svn rev 40502. ok kettenis@ millert@ lteo@
-rw-r--r--usr.bin/indent/indent.111
-rw-r--r--usr.bin/indent/indent.c7
2 files changed, 11 insertions, 7 deletions
diff --git a/usr.bin/indent/indent.1 b/usr.bin/indent/indent.1
index 628ae6a608e..c5d8311d2eb 100644
--- a/usr.bin/indent/indent.1
+++ b/usr.bin/indent/indent.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: indent.1,v 1.21 2013/06/20 06:28:15 jsg Exp $
+.\" $OpenBSD: indent.1,v 1.22 2013/06/21 06:49:42 jsg Exp $
.\"
.\" Copyright (c) 1980, 1990, 1993
.\" The Regents of the University of California.
@@ -32,7 +32,7 @@
.\"
.\" from: @(#)indent.1 8.1 (Berkeley) 7/1/93
.\"
-.Dd $Mdocdate: June 20 2013 $
+.Dd $Mdocdate: June 21 2013 $
.Dt INDENT 1
.Os
.Sh NAME
@@ -41,7 +41,7 @@
.Sh SYNOPSIS
.Nm indent
.Bk -words
-.Ar input-file Op Ar output-file
+.Op Ar input-file Op Ar output-file
.Op Fl bad | nbad
.Op Fl bap | nbap
.Op Fl bbb | nbbb
@@ -115,6 +115,11 @@ is specified,
checks to make sure it is different from
.Ar input-file .
.Pp
+If no
+.Ar input-file
+is specified
+input is read from stdin and the formatted file is written to stdout.
+.Pp
The options listed below control the formatting style imposed by
.Nm .
.Bl -tag -width Op
diff --git a/usr.bin/indent/indent.c b/usr.bin/indent/indent.c
index 9af962af1a4..33a7f7835f7 100644
--- a/usr.bin/indent/indent.c
+++ b/usr.bin/indent/indent.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: indent.c,v 1.21 2013/06/20 06:28:15 jsg Exp $ */
+/* $OpenBSD: indent.c,v 1.22 2013/06/21 06:49:42 jsg Exp $ */
/*
* Copyright (c) 1980, 1993
@@ -198,11 +198,10 @@ main(int argc, char **argv)
set_option(argv[i]);
} /* end of for */
if (input == NULL) {
- fprintf(stderr, "usage: indent input-file [output-file] [options]\n");
- exit(1);
+ input = stdin;
}
if (output == NULL) {
- if (troff)
+ if (troff || input == stdin)
output = stdout;
else {
out_name = in_name;