summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorThomas Gellekum <tg@FreeBSD.org>1999-08-26 08:16:27 +0000
committerThomas Gellekum <tg@FreeBSD.org>1999-08-26 08:16:27 +0000
commit8f0561cc424117891c596a530f5fb196c4b85acc (patch)
tree09657a98c573adbb1769e5d40cf627af97804102 /bin
parent6fd578c4351e4739d8a779cdd100d1b77c94830e (diff)
downloadsrc-test2-8f0561cc424117891c596a530f5fb196c4b85acc.tar.gz
src-test2-8f0561cc424117891c596a530f5fb196c4b85acc.zip
Notes
Diffstat (limited to 'bin')
-rw-r--r--bin/sh/miscbltin.c18
-rw-r--r--bin/sh/sh.120
2 files changed, 21 insertions, 17 deletions
diff --git a/bin/sh/miscbltin.c b/bin/sh/miscbltin.c
index 4c8d96f16d9f..a270ac8b5ab8 100644
--- a/bin/sh/miscbltin.c
+++ b/bin/sh/miscbltin.c
@@ -39,7 +39,7 @@
static char sccsid[] = "@(#)miscbltin.c 8.4 (Berkeley) 5/4/95";
#endif
static const char rcsid[] =
- "$Id: miscbltin.c,v 1.18 1998/12/16 04:45:35 imp Exp $";
+ "$Id: miscbltin.c,v 1.19 1999/05/08 10:21:56 kris Exp $";
#endif /* not lint */
/*
@@ -71,8 +71,8 @@ extern char **argptr; /* argument list for builtin command */
/*
- * The read builtin. The -e option causes backslashes to escape the
- * following character.
+ * The read builtin. The -r option causes backslashes to be treated like
+ * ordinary characters.
*
* This uses unbuffered input, which may be avoidable in some cases.
*/
@@ -85,7 +85,7 @@ readcmd(argc, argv)
char **ap;
int backslash;
char c;
- int eflag;
+ int rflag;
char *prompt;
char *ifs;
char *p;
@@ -98,17 +98,19 @@ readcmd(argc, argv)
struct termios told, tnew;
int tsaved;
- eflag = 0;
+ rflag = 0;
prompt = NULL;
tv.tv_sec = -1;
tv.tv_usec = 0;
- while ((i = nextopt("ep:t:")) != '\0') {
+ while ((i = nextopt("erp:t:")) != '\0') {
switch(i) {
case 'p':
prompt = optarg;
break;
case 'e':
- eflag = 1;
+ break;
+ case 'r':
+ rflag = 1;
break;
case 't':
tv.tv_sec = strtol(optarg, &tvptr, 0);
@@ -184,7 +186,7 @@ readcmd(argc, argv)
STPUTC(c, p);
continue;
}
- if (eflag && c == '\\') {
+ if (!rflag && c == '\\') {
backslash++;
continue;
}
diff --git a/bin/sh/sh.1 b/bin/sh/sh.1
index e7bdcc4c7be8..66baae6a56b5 100644
--- a/bin/sh/sh.1
+++ b/bin/sh/sh.1
@@ -33,7 +33,7 @@
.\" SUCH DAMAGE.
.\"
.\" from: @(#)sh.1 8.6 (Berkeley) 5/4/95
-.\" $Id: sh.1,v 1.27 1999/04/03 11:41:46 cracauer Exp $
+.\" $Id: sh.1,v 1.28 1999/04/19 18:48:26 max Exp $
.\"
.Dd May 5, 1995
.Dt SH 1
@@ -1150,7 +1150,7 @@ is rather than recomputing it each time. This makes
it faster. However, if the current directory is
renamed, the builtin version of pwd will continue to
print the old name for the directory.
-.It Li "read [ -p prompt ] [ -t timeout ] [ -e ] variable ...
+.It Li "read [ -p prompt ] [ -t timeout ] [ -er ] variable ...
The prompt is printed if the -p option is specified
and the standard input is a terminal. Then a line is
read from the standard input. The trailing newline
@@ -1163,6 +1163,14 @@ separated them) are assigned to the last variable.
If there are more variables than pieces, the remaining
variables are assigned the null string.
.Pp
+Backslashes are treated specially, unless the -r option is
+specified. If a backslash is followed by
+a newline, the backslash and the newline will be
+deleted. If a backslash is followed by any other
+character, the backslash will be deleted and the following
+character will be treated as though it were
+not in IFS, even if it is.
+.Pp
If the -t option is specified the timeout elapses
before any input is supplied, the read command will
return without assigning any values. The timeout value
@@ -1170,13 +1178,7 @@ may optionally be followed by one of 's', 'm' or 'h' to
explicitly specify seconds, minutes or or hours. If none
is supplied, 's' is assumed.
.Pp
-The -e option causes any backslashes in the input to
-be treated specially. If a backslash is followed by
-a newline, the backslash and the newline will be
-deleted. If a backslash is followed by any other
-character, the backslash will be deleted and the following
-character will be treated as though it were
-not in IFS, even if it is.
+The -e option exists only for backward compatibility with older scripts.
.It readonly name ...
The specified names are marked as read only, so that
they cannot be subsequently modified or unset. The shell