summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Sonnenschein <johns@joyent.com>2011-11-24 23:29:10 +0000
committerJohn Sonnenschein <johns@joyent.com>2011-11-24 23:29:10 +0000
commit58474c20a5282db4eba6c3a9f4c028e06988e09e (patch)
treeb444f860893c4bcde1b1716b9e493ba79f3ad574
parent97c04c3c87e99538f4220453d9385840a5e1d714 (diff)
downloadillumos-joyent-58474c20a5282db4eba6c3a9f4c028e06988e09e.tar.gz
Revert "586 sed -i should take an "optional" argument"
This reverts commit e50226eccc6dfcba3cc6f0df38438900e3df225c.
-rw-r--r--usr/src/cmd/sed/main.c27
-rw-r--r--usr/src/man/man1/sed.124
2 files changed, 21 insertions, 30 deletions
diff --git a/usr/src/cmd/sed/main.c b/usr/src/cmd/sed/main.c
index 93e14bb09b..59a6da8e22 100644
--- a/usr/src/cmd/sed/main.c
+++ b/usr/src/cmd/sed/main.c
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2011 Gary Mills
- * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2010 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 1992 Diomidis Spinellis.
* Copyright (c) 1992, 1993
* The Regents of the University of California. All rights reserved.
@@ -41,9 +41,7 @@
#include <err.h>
#include <errno.h>
#include <fcntl.h>
-#include <getopt.h>
#include <libgen.h>
-#include <libintl.h>
#include <limits.h>
#include <locale.h>
#include <regex.h>
@@ -52,6 +50,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <libintl.h>
#include "defs.h"
#include "extern.h"
@@ -106,11 +105,6 @@ static char tmpfname[PATH_MAX]; /* Temporary file name (for in-place editing) */
static const char *inplace; /* Inplace edit file extension. */
ulong_t linenum;
-static const struct option lopts[] = {
- {"in-place", optional_argument, NULL, 'i'},
- {NULL, 0, NULL, 0}
-};
-
static void add_compunit(enum e_cut, char *);
static void add_file(char *);
static void usage(void);
@@ -133,18 +127,14 @@ main(int argc, char *argv[])
fflag = 0;
inplace = NULL;
- while ((c = getopt_long(argc, argv, "EI::ae:f:i::lnr", lopts, NULL)) !=
- -1)
+ while ((c = getopt(argc, argv, "EI:ae:f:i:lnr")) != -1)
switch (c) {
case 'r': /* Gnu sed compat */
case 'E':
rflags = REG_EXTENDED;
break;
case 'I':
- if (optarg != NULL)
- inplace = optarg;
- else
- inplace = "";
+ inplace = optarg;
ispan = 1; /* span across input files */
break;
case 'a':
@@ -161,10 +151,7 @@ main(int argc, char *argv[])
add_compunit(CU_FILE, optarg);
break;
case 'i':
- if (optarg != NULL)
- inplace = optarg;
- else
- inplace = "";
+ inplace = optarg;
ispan = 0; /* don't span across input files */
break;
case 'l':
@@ -205,8 +192,8 @@ main(int argc, char *argv[])
static void
usage(void)
{
- (void) fputs(_("usage: sed script [-Ealn] [-i[extension]] [file...]\n"
- " sed [-Ealn] [-i[extension]] [-e script]... "
+ (void) fputs(_("usage: sed script [-Ealn] [-i extension] [file...]\n"
+ " sed [-Ealn] [-i extension] [-e script]... "
"[-f script_file]... [file...]\n"),
stderr);
exit(1);
diff --git a/usr/src/man/man1/sed.1 b/usr/src/man/man1/sed.1
index ded1c15fa3..9ec2b67dd9 100644
--- a/usr/src/man/man1/sed.1
+++ b/usr/src/man/man1/sed.1
@@ -1,8 +1,6 @@
.\" Copyright (c) 1992, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
-.\" Copyright 2011 Nexenta Systems, Inc. All rights reserved.
-.\"
.\" This code is derived from software contributed to Berkeley by
.\" the Institute of Electrical and Electronics Engineers, Inc.
.\"
@@ -30,7 +28,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.TH SED 1 "Nov 2, 2011"
+.TH SED 1 "May 24, 2009"
.SH NAME
\fBsed\fP
\- stream editor
@@ -45,7 +43,8 @@
[\fB\-Ealnr\fP]
[\fB\-e\fP \fIcommand\fP]
[\fB\-f\fP \fIcommand_file\fP]
-[\fB\-I\fP[\fIextension\fP] | \fB\-i\fP[\fIextension\fP]]
+[\fB\-I\fP \fIextension\fP]
+[\fB\-i\fP \fIextension\fP]
[\fIfile ...\fP]
.SH DESCRIPTION
The
@@ -98,11 +97,16 @@ Append the editing commands found in the file
to the list of commands.
The editing commands should each be listed on a separate line.
.TP
-\fB\-I\fP[\fIextension\fP]
-Edit files in-place, saving backups if \fIextension\fP was specified.
-It is not recommended to omit saving backups when in-place editing files,
-as you risk corruption or partial content in situations where disk
-space is exhausted, etc.
+\fB\-I\fP \fIextension\fP
+Edit files in-place, saving backups with the specified
+\fIextension\fP.
+If a zero-length
+\fIextension\fP
+is given, no backup will be saved.
+It is not recommended to give a zero-length
+\fIextension\fP
+when in-place editing files, as you risk corruption or partial content
+in situations where disk space is exhausted, etc.
Note that in-place editing with
\fB\-I\fP
@@ -120,7 +124,7 @@ where using
\fB\-i\fP
is desired.
.TP
-\fB\-i\fP[\fIextension\fP]
+\fB\-i\fP \fIextension\fP
Edit files in-place similarly to
\fB\-I\fP,
but treat each file independently from other files.