* Copyright (c) 1991, 1993
* The Regents of the University of California. All rights reserved.
* This code is derived from software contributed to Berkeley by
* %sccs.include.redist.c%
static char sccsid
[] = "@(#)miscbltin.c 8.1 (Berkeley) %G%";
extern char **argptr
; /* argument list for builtin command */
* The read builtin. The -e option causes backslashes to escape the
* This uses unbuffered input, which may be avoidable in some cases.
readcmd(argc
, argv
) char **argv
; {
while ((i
= nextopt("ep:")) != '\0') {
if (prompt
&& isatty(0)) {
if ((ap
= argptr
) == NULL
)
if ((ifs
= bltinlookup("IFS", 1)) == NULL
)
if (read(0, &c
, 1) != 1) {
if (eflag
&& c
== '\\') {
if (startword
&& *ifs
== ' ' && strchr(ifs
, c
)) {
if (backslash
&& c
== '\\') {
if (read(0, &c
, 1) != 1) {
} else if (ap
[1] != NULL
&& strchr(ifs
, c
) != NULL
) {
setvar(*ap
, stackblock(), 0);
setvar(*ap
, stackblock(), 0);
umaskcmd(argc
, argv
) char **argv
; {
if ((p
= argv
[1]) == NULL
) {
out1fmt("%.4o\n", mask
); /* %#o might be better */
if ((unsigned)(i
= *p
- '0') >= 8)
error("Illegal number: %s", argv
[1]);