Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/bin/ed add -S to disable ! commands.
details: https://anonhg.NetBSD.org/src/rev/ec1a5b711d21
branches: trunk
changeset: 360895:ec1a5b711d21
user: christos <christos%NetBSD.org@localhost>
date: Thu Apr 05 18:44:57 2018 +0000
description:
add -S to disable ! commands.
diffstat:
bin/ed/ed.1 | 13 ++++++++++---
bin/ed/main.c | 16 ++++++++++++----
2 files changed, 22 insertions(+), 7 deletions(-)
diffs (113 lines):
diff -r 0d6cb7c49fe0 -r ec1a5b711d21 bin/ed/ed.1
--- a/bin/ed/ed.1 Thu Apr 05 16:31:54 2018 +0000
+++ b/bin/ed/ed.1 Thu Apr 05 18:44:57 2018 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: ed.1,v 1.31 2017/07/03 21:33:23 wiz Exp $
+.\" $NetBSD: ed.1,v 1.32 2018/04/05 18:44:57 christos Exp $
.\" $OpenBSD: ed.1,v 1.42 2003/07/27 13:25:43 jmc Exp $
.\"
.\" Copyright (c) 1993 Andrew Moore, Talke Studio.
@@ -25,7 +25,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd January 23, 2002
+.Dd April 23, 2002
.Dt ED 1
.Os
.Sh NAME
@@ -34,7 +34,7 @@
.Sh SYNOPSIS
.Nm
.Op Fl
-.Op Fl Esx
+.Op Fl ESsx
.Op Fl p Ar string
.Op Ar file
.Sh DESCRIPTION
@@ -130,6 +130,12 @@
.It Fl E
Enables the use of extended regular expressions instead of the basic
regular expressions that are normally used.
+.It Fl S
+Disables using of the
+.Dq !
+command (execuring a subshell).
+Intended to be used by batch jobs like
+.Xr patch 1 .
.It Fl p Ar string
Specifies a command prompt.
This may be toggled on and off with the
@@ -955,6 +961,7 @@
.Xr sed 1 ,
.Xr sh 1 ,
.Xr vi 1 ,
+.Xr patch 1 ,
.Xr regex 3
.Pp
USD:09-10
diff -r 0d6cb7c49fe0 -r ec1a5b711d21 bin/ed/main.c
--- a/bin/ed/main.c Thu Apr 05 16:31:54 2018 +0000
+++ b/bin/ed/main.c Thu Apr 05 18:44:57 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.28 2016/03/02 19:11:28 christos Exp $ */
+/* $NetBSD: main.c,v 1.29 2018/04/05 18:44:57 christos Exp $ */
/* main.c: This file contains the main control and user-interface routines
for the ed line editor. */
@@ -39,7 +39,7 @@
#if 0
static char *rcsid = "@(#)main.c,v 1.1 1994/02/01 00:34:42 alm Exp";
#else
-__RCSID("$NetBSD: main.c,v 1.28 2016/03/02 19:11:28 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.29 2018/04/05 18:44:57 christos Exp $");
#endif
#endif /* not lint */
@@ -94,6 +94,7 @@
int red = 0; /* if set, restrict shell/directory access */
int ere = 0; /* if set, use extended regexes */
int scripted = 0; /* if set, suppress diagnostics */
+int secure = 0; /* is set, ! is not allowed */
int sigflags = 0; /* if set, signals received while mutex set */
int sigactive = 0; /* if set, signal handlers are enabled */
@@ -105,7 +106,7 @@
const char *dps = "*"; /* default command-line prompt */
-static const char usage[] = "Usage: %s [-] [-sxE] [-p string] [name]\n";
+static const char usage[] = "Usage: %s [-] [-ESsx] [-p string] [name]\n";
/* ed: line editor */
int
@@ -118,7 +119,7 @@
red = (n = strlen(argv[0])) > 2 && argv[0][n - 3] == 'r';
top:
- while ((c = getopt(argc, argv, "p:sxE")) != -1)
+ while ((c = getopt(argc, argv, "p:sxES")) != -1)
switch(c) {
case 'p': /* set prompt */
prompt = optarg;
@@ -137,6 +138,9 @@
case 'E':
ere = REG_EXTENDED;
break;
+ case 'S': /* ! is not allowed */
+ secure = 1;
+ break;
default:
fprintf(stderr, usage, getprogname());
exit(1);
@@ -861,6 +865,10 @@
printf("%ld\n", addr_cnt ? second_addr : addr_last);
break;
case '!':
+ if (secure) {
+ seterrmsg("'!' not allowed");
+ return ERR;
+ }
if (addr_cnt > 0) {
seterrmsg("unexpected address");
return ERR;
Home |
Main Index |
Thread Index |
Old Index