summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/mg/main.c13
-rw-r--r--usr.bin/mg/mg.18
2 files changed, 14 insertions, 7 deletions
diff --git a/usr.bin/mg/main.c b/usr.bin/mg/main.c
index 1639f2c17ba..ebda8f7e45e 100644
--- a/usr.bin/mg/main.c
+++ b/usr.bin/mg/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.80 2015/11/19 19:30:44 bentley Exp $ */
+/* $OpenBSD: main.c,v 1.81 2015/12/24 09:07:47 lum Exp $ */
/* This file is in the public domain. */
@@ -42,7 +42,7 @@ extern void closetags(void);
static __dead void
usage()
{
- fprintf(stderr, "usage: %s [-n] [-f mode] [+number] [file ...]\n",
+ fprintf(stderr, "usage: %s [-nR] [-f mode] [+number] [file ...]\n",
__progname);
exit(1);
}
@@ -53,14 +53,17 @@ main(int argc, char **argv)
char *cp, *init_fcn_name = NULL;
PF init_fcn = NULL;
int o, i, nfiles;
- int nobackups = 0;
+ int nobackups = 0, bro = 0;
struct buffer *bp = NULL;
if (pledge("stdio rpath wpath cpath fattr getpw tty proc exec", NULL) == -1)
err(1, "pledge");
- while ((o = getopt(argc, argv, "nf:")) != -1)
+ while ((o = getopt(argc, argv, "nRf:")) != -1)
switch (o) {
+ case 'R':
+ bro = 1;
+ break;
case 'n':
nobackups = 1;
break;
@@ -170,6 +173,8 @@ notnum:
init_fcn(FFOTHARG, 1);
nfiles++;
}
+ if (bro)
+ curbp->b_flag |= BFREADONLY;
}
}
}
diff --git a/usr.bin/mg/mg.1 b/usr.bin/mg/mg.1
index ae315d1e2fe..e3130d9d858 100644
--- a/usr.bin/mg/mg.1
+++ b/usr.bin/mg/mg.1
@@ -1,7 +1,7 @@
-.\" $OpenBSD: mg.1,v 1.97 2015/12/22 15:33:16 lum Exp $
+.\" $OpenBSD: mg.1,v 1.98 2015/12/24 09:07:47 lum Exp $
.\" This file is in the public domain.
.\"
-.Dd $Mdocdate: December 22 2015 $
+.Dd $Mdocdate: December 24 2015 $
.Dt MG 1
.Os
.Sh NAME
@@ -9,7 +9,7 @@
.Nd emacs-like text editor
.Sh SYNOPSIS
.Nm mg
-.Op Fl n
+.Op Fl nR
.Op Fl f Ar mode
.Op + Ns Ar number
.Op Ar
@@ -40,6 +40,8 @@ arguments on the command line, including the
scratch buffer and all files.
.It Fl n
Turn off backup file generation.
+.It Fl R
+Files specified on the command line will be opened read-only.
.El
.Sh WINDOWS AND BUFFERS
When a file is loaded into