Per 1003.2, the (builtin) read utility shall treat the backslash as an
escape character (including line continuation), unless the `-r' option is specified: * adopt to this behaviour, add the `-r' option to disable it; * remove the `-e' option, which was previously necessary to get this behaviour.
This commit is contained in:
parent
ad5a9cf050
commit
3780e6aa5d
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: miscbltin.c,v 1.19 1997/07/04 21:02:09 christos Exp $ */
|
||||
/* $NetBSD: miscbltin.c,v 1.20 1997/11/05 14:05:28 kleink Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1991, 1993
|
||||
|
@ -41,7 +41,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)miscbltin.c 8.4 (Berkeley) 5/4/95";
|
||||
#else
|
||||
__RCSID("$NetBSD: miscbltin.c,v 1.19 1997/07/04 21:02:09 christos Exp $");
|
||||
__RCSID("$NetBSD: miscbltin.c,v 1.20 1997/11/05 14:05:28 kleink Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -66,7 +66,7 @@ __RCSID("$NetBSD: miscbltin.c,v 1.19 1997/07/04 21:02:09 christos Exp $");
|
|||
#include "miscbltin.h"
|
||||
#include "mystring.h"
|
||||
|
||||
#undef eflag
|
||||
#undef rflag
|
||||
|
||||
extern char **argptr; /* argument list for builtin command */
|
||||
|
||||
|
@ -86,7 +86,7 @@ readcmd(argc, argv)
|
|||
char **ap;
|
||||
int backslash;
|
||||
char c;
|
||||
int eflag;
|
||||
int rflag;
|
||||
char *prompt;
|
||||
char *ifs;
|
||||
char *p;
|
||||
|
@ -94,13 +94,13 @@ readcmd(argc, argv)
|
|||
int status;
|
||||
int i;
|
||||
|
||||
eflag = 0;
|
||||
rflag = 0;
|
||||
prompt = NULL;
|
||||
while ((i = nextopt("ep:")) != '\0') {
|
||||
while ((i = nextopt("p:r")) != '\0') {
|
||||
if (i == 'p')
|
||||
prompt = optarg;
|
||||
else
|
||||
eflag = 1;
|
||||
rflag = 1;
|
||||
}
|
||||
if (prompt && isatty(0)) {
|
||||
out2str(prompt);
|
||||
|
@ -127,7 +127,7 @@ readcmd(argc, argv)
|
|||
STPUTC(c, p);
|
||||
continue;
|
||||
}
|
||||
if (eflag && c == '\\') {
|
||||
if (!rflag && c == '\\') {
|
||||
backslash++;
|
||||
continue;
|
||||
}
|
||||
|
|
15
bin/sh/sh.1
15
bin/sh/sh.1
|
@ -1,4 +1,4 @@
|
|||
.\" $NetBSD: sh.1,v 1.21 1997/07/10 23:07:04 phil Exp $
|
||||
.\" $NetBSD: sh.1,v 1.22 1997/11/05 14:05:31 kleink Exp $
|
||||
.\" Copyright (c) 1991, 1993
|
||||
.\" The Regents of the University of California. All rights reserved.
|
||||
.\"
|
||||
|
@ -1263,7 +1263,7 @@ it faster. However, if the current directory is
|
|||
renamed, the builtin version of pwd will continue to
|
||||
print the old name for the directory.
|
||||
.TP
|
||||
read [ -p prompt ] [ -e ] variable...
|
||||
read [ -p prompt ] [ -r ] 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
|
||||
|
@ -1276,13 +1276,10 @@ separated them) are assigned to the last variable.
|
|||
If there are more variables than pieces, the remaining
|
||||
variables are assigned the null string.
|
||||
.sp
|
||||
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.
|
||||
By default, unless the -r option is specified, the backslash
|
||||
(\\) acts as an escape character, causing the following
|
||||
character to be treated literally. If a backslash is followed
|
||||
by a newline, the backslash and the newline will be deleted.
|
||||
.TP
|
||||
readonly name...
|
||||
The specified names are marked as read only, so that
|
||||
|
|
Loading…
Reference in New Issue