summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1997-07-01 22:34:08 +0000
committerbde <bde@FreeBSD.org>1997-07-01 22:34:08 +0000
commit8197c5b09b2f0f0b82d6629879a7e2ce3133322a (patch)
tree7c0333797bb062790f31c3a40f2c195da6a65e17 /bin
parent2ea77a1af1f7b26dc808b140e95ba9710decc64e (diff)
downloadFreeBSD-src-8197c5b09b2f0f0b82d6629879a7e2ce3133322a.zip
FreeBSD-src-8197c5b09b2f0f0b82d6629879a7e2ce3133322a.tar.gz
Import Lite2's src/bin. All files in src/bin are off the vendor branch,
so this doesn't change the active versions.
Diffstat (limited to 'bin')
-rw-r--r--bin/cat/cat.113
-rw-r--r--bin/cat/cat.c7
-rw-r--r--bin/cp/cp.c17
-rw-r--r--bin/csh/Makefile4
-rw-r--r--bin/csh/USD.doc/csh.13
-rw-r--r--bin/csh/USD.doc/csh.23
-rw-r--r--bin/csh/USD.doc/csh.37
-rw-r--r--bin/csh/USD.doc/csh.43
-rw-r--r--bin/csh/csh.114
-rw-r--r--bin/csh/csh.c78
-rw-r--r--bin/csh/csh.h6
-rw-r--r--bin/csh/dir.c6
-rw-r--r--bin/csh/dol.c13
-rw-r--r--bin/csh/exec.c22
-rw-r--r--bin/csh/file.c26
-rw-r--r--bin/csh/func.c53
-rw-r--r--bin/csh/hist.c10
-rw-r--r--bin/csh/lex.c4
-rw-r--r--bin/csh/proc.c89
-rw-r--r--bin/csh/sem.c40
-rw-r--r--bin/csh/set.c10
-rw-r--r--bin/date/date.110
-rw-r--r--bin/date/date.c8
-rw-r--r--bin/date/netdate.c3
-rw-r--r--bin/hostname/hostname.19
-rw-r--r--bin/hostname/hostname.c19
-rw-r--r--bin/kill/kill.172
-rw-r--r--bin/kill/kill.c97
-rw-r--r--bin/ls/ls.113
-rw-r--r--bin/ls/ls.c16
-rw-r--r--bin/ls/print.c5
-rw-r--r--bin/ls/stat_flags.c7
-rw-r--r--bin/ls/util.c5
-rw-r--r--bin/ps/fmt.c6
-rw-r--r--bin/pwd/pwd.16
-rw-r--r--bin/rm/rm.111
-rw-r--r--bin/rm/rm.c95
-rw-r--r--bin/rmail/rmail.c44
-rw-r--r--bin/stty/key.c9
-rw-r--r--bin/stty/stty.19
40 files changed, 563 insertions, 309 deletions
diff --git a/bin/cat/cat.1 b/bin/cat/cat.1
index 102b22e..91ce3fd 100644
--- a/bin/cat/cat.1
+++ b/bin/cat/cat.1
@@ -32,9 +32,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)cat.1 8.1 (Berkeley) 6/29/93
+.\" @(#)cat.1 8.3 (Berkeley) 5/2/95
.\"
-.Dd June 29, 1993
+.Dd May 2, 1995
.Dt CAT 1
.Os BSD 3
.Sh NAME
@@ -68,9 +68,7 @@ option, and displays a dollar sign
at the end of each line
as well.
.It Fl n
-Number the
-.Ar output
-lines, starting at 1.
+Number the output lines, starting at 1.
.It Fl s
Squeeze multiple adjacent empty lines, causing the output to be
single spaced.
@@ -78,7 +76,7 @@ single spaced.
Implies the
.Fl v
option, and displays tab characters as
-.Pq Ql ^I
+.Ql ^I
as well.
.It Fl u
The
@@ -108,7 +106,8 @@ will cause the original data in file1 to be destroyed!
.Xr head 1 ,
.Xr more 1 ,
.Xr pr 1 ,
-.Xr tail 1
+.Xr tail 1 ,
+.Xr vis 1
.Rs
.%A Rob Pike
.%T "UNIX Style, or cat -v Considered Harmful"
diff --git a/bin/cat/cat.c b/bin/cat/cat.c
index 30e5bfc..0b2e1a7 100644
--- a/bin/cat/cat.c
+++ b/bin/cat/cat.c
@@ -41,7 +41,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)cat.c 8.1 (Berkeley) 7/19/93";
+static char sccsid[] = "@(#)cat.c 8.2 (Berkeley) 4/27/95";
#endif /* not lint */
#include <sys/param.h>
@@ -73,7 +73,7 @@ main(argc, argv)
extern int optind;
int ch;
- while ((ch = getopt(argc, argv, "benstuv")) != EOF)
+ while ((ch = getopt(argc, argv, "benstuv")) != -1)
switch (ch) {
case 'b':
bflag = nflag = 1; /* -b implies -n */
@@ -96,6 +96,7 @@ main(argc, argv)
case 'v':
vflag = 1;
break;
+ default:
case '?':
(void)fprintf(stderr,
"usage: cat [-benstuv] [-] [file ...]\n");
@@ -240,7 +241,7 @@ raw_cat(rfd)
err(1, "%s", filename);
bsize = MAX(sbuf.st_blksize, 1024);
if ((buf = malloc((u_int)bsize)) == NULL)
- err(1, "");
+ err(1, NULL);
}
while ((nr = read(rfd, buf, bsize)) > 0)
for (off = 0; nr; nr -= nw, off += nw)
diff --git a/bin/cp/cp.c b/bin/cp/cp.c
index b58bb99..61a1f79 100644
--- a/bin/cp/cp.c
+++ b/bin/cp/cp.c
@@ -41,7 +41,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)cp.c 8.2 (Berkeley) 4/1/94";
+static char sccsid[] = "@(#)cp.c 8.5 (Berkeley) 4/29/95";
#endif /* not lint */
/*
@@ -49,7 +49,7 @@ static char sccsid[] = "@(#)cp.c 8.2 (Berkeley) 4/1/94";
*
* The global PATH_T structure "to" always contains the path to the
* current target file. Since fts(3) does not change directories,
- * this path can be either absolute or dot-realative.
+ * this path can be either absolute or dot-relative.
*
* The basic algorithm is to initialize "to" and use fts(3) to traverse
* the file hierarchy rooted in the argument list. A trivial case is the
@@ -341,6 +341,13 @@ copy(argv, type, fts_options)
(void)fts_set(ftsp, curr, FTS_SKIP);
continue;
}
+ if (!S_ISDIR(curr->fts_statp->st_mode) &&
+ S_ISDIR(to_stat.st_mode)) {
+ warnx("cannot overwrite directory %s with non-directory %s",
+ to.p_path, curr->fts_path);
+ rval = 1;
+ continue;
+ }
dne = 0;
}
@@ -371,7 +378,7 @@ copy(argv, type, fts_options)
err(1, "%s", to.p_path);
} else if (!S_ISDIR(to_stat.st_mode)) {
errno = ENOTDIR;
- err(1, "%s: %s", to.p_path);
+ err(1, "%s", to.p_path);
}
/*
* If not -p and directory didn't exist, set it to be
@@ -395,10 +402,10 @@ copy(argv, type, fts_options)
rval = 1;
break;
case S_IFIFO:
- if (Rflag)
+ if (Rflag) {
if (copy_fifo(curr->fts_statp, !dne))
rval = 1;
- else
+ } else
if (copy_file(curr, dne))
rval = 1;
break;
diff --git a/bin/csh/Makefile b/bin/csh/Makefile
index e29f549..9b81560 100644
--- a/bin/csh/Makefile
+++ b/bin/csh/Makefile
@@ -1,4 +1,4 @@
-# @(#)Makefile 8.1 (Berkeley) 5/31/93
+# @(#)Makefile 8.2 (Berkeley) 3/22/95
#
# C Shell with process control; VM/UNIX VAX Makefile
# Bill Joy UC Berkeley; Jim Kulp IIASA, Austria
@@ -8,7 +8,7 @@
PROG= csh
DFLAGS=-DBUILTIN -DFILEC -DNLS -DSHORT_STRINGS
#CFLAGS+=-g
-#CFLAGS+=-Wall -ansi -pedantic
+#CFLAGS+=-Wall
CFLAGS+=-I${.CURDIR} -I. ${DFLAGS}
SRCS= alloc.c char.c const.c csh.c dir.c dol.c err.c exec.c exp.c file.c \
func.c glob.c hist.c init.c lex.c misc.c parse.c printf.c proc.c \
diff --git a/bin/csh/USD.doc/csh.1 b/bin/csh/USD.doc/csh.1
index 9b8e394..199ba8f 100644
--- a/bin/csh/USD.doc/csh.1
+++ b/bin/csh/USD.doc/csh.1
@@ -29,7 +29,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)csh.1 8.1 (Berkeley) 6/8/93
+.\" @(#)csh.1 8.2 (Berkeley) 5/16/94
.\"
.EH 'USD:4-%''An Introduction to the C shell'
.OH 'An Introduction to the C shell''USD:4-%'
@@ -1009,4 +1009,3 @@ The next section will introduce many features particular to
so you should change your shell to
.I csh
before you begin reading it.
-.bp
diff --git a/bin/csh/USD.doc/csh.2 b/bin/csh/USD.doc/csh.2
index 610105c..68fcbc4 100644
--- a/bin/csh/USD.doc/csh.2
+++ b/bin/csh/USD.doc/csh.2
@@ -29,7 +29,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)csh.2 8.1 (Berkeley) 6/8/93
+.\" @(#)csh.2 8.2 (Berkeley) 5/16/94
.\"
.nr H1 1
.NH
@@ -1302,4 +1302,3 @@ sequence with a number of different arguments.
If you intend to use \s-2UNIX\s0 a lot you you should look through
the rest of this document and the csh manual pages (section1) to become familiar
with the other facilities which are available to you.
-.bp
diff --git a/bin/csh/USD.doc/csh.3 b/bin/csh/USD.doc/csh.3
index cf8af73..1f77a07 100644
--- a/bin/csh/USD.doc/csh.3
+++ b/bin/csh/USD.doc/csh.3
@@ -29,7 +29,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)csh.3 8.1 (Berkeley) 6/8/93
+.\" @(#)csh.3 8.2 (Berkeley) 5/16/94
.\"
.nr H1 2
.NH
@@ -308,9 +308,11 @@ of the shell and some of its control structure follows:
# to the directory ~/backup if they differ from the files
# already in ~/backup
#
+.DE
+.sp -1
+.DS
set noglob
foreach i ($argv)
-
if ($i !~ *.c) continue # not a .c file so do nothing
if (! \-r ~/backup/$i:t) then
@@ -647,4 +649,3 @@ There is also another quotation mechanism using `"' which allows
only some of the expansion mechanisms we have so far discussed to occur
on the quoted string and serves to make this string into a single word
as `\'' does.
-.bp
diff --git a/bin/csh/USD.doc/csh.4 b/bin/csh/USD.doc/csh.4
index ee862df..6efb30e 100644
--- a/bin/csh/USD.doc/csh.4
+++ b/bin/csh/USD.doc/csh.4
@@ -29,7 +29,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)csh.4 8.1 (Berkeley) 6/8/93
+.\" @(#)csh.4 8.2 (Berkeley) 5/16/94
.\"
.nr H1 3
.NH
@@ -175,4 +175,3 @@ The shell has a number of command line option flags mostly of use
in writing \s-2UNIX\s0 programs,
and debugging shell scripts.
See the csh(1) manual section for a list of these options.
-.bp
diff --git a/bin/csh/csh.1 b/bin/csh/csh.1
index 58a9ddb..1667847 100644
--- a/bin/csh/csh.1
+++ b/bin/csh/csh.1
@@ -29,9 +29,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)csh.1 8.2 (Berkeley) 1/21/94
+.\" @(#)csh.1 8.4 (Berkeley) 6/1/94
.\"
-.Dd January 21, 1994
+.Dd June 1, 1994
.Dt CSH 1
.Os BSD 4
.Sh NAME
@@ -360,6 +360,7 @@ bench class dev mbox xmpl.out
and the input is
.Pp
.Dl % vi ch<escape>
+.ne 1i
.Pp
.Nm csh
will complete the prefix ``ch''
@@ -753,6 +754,7 @@ If the last number of a range is omitted it defaults to `$#name'.
The selector `*' selects all words.
It is not an error for a range to be empty if the second argument is omitted
or in range.
+.ne 1i
.It $#name
.It ${#name}
Gives the number of words in the variable.
@@ -1036,6 +1038,7 @@ form of the
.Ic if
statement require that the major keywords appear in a single simple command
on an input line as shown below.
+.pl +1
.Pp
If the shell's input is not seekable,
the shell buffers up input whenever a loop is being read
@@ -1374,6 +1377,8 @@ beyond the end of the program text),
size of the automatically-extended stack region), and
.Ar coredumpsize
(the size of the largest core dump that will be created).
+.lp -1
+.ne 1i
.Pp
The
.Ar maximum-use
@@ -1476,6 +1481,7 @@ discards the
.Ar n Ns \'th
entry in the stack.
The members of the directory stack are numbered from the top starting at 0.
+.ne 1i
.Pp
.It Ic pushd
.It Ic pushd Ar name
@@ -1603,6 +1609,7 @@ The second form performs the same function on the specified variable.
.Pp
.It Ic source Ar name
.It Ic source Fl h Ar name
+.pl -1
The shell reads commands from
.Ar name .
.Ic Source
@@ -1826,6 +1833,7 @@ as inferior
processes will import the definition of
.Ar path
from the environment, and re-export it if you then change it.
+.ne 1i
.Bl -tag -width histchars
.It Ic argv
Set to the arguments to the shell, it is from this variable that
@@ -2034,6 +2042,7 @@ from affecting the current shell.
If the file has execute permissions but is not an
executable binary to the system, then it is assumed to be a
file containing shell commands and a new shell is spawned to read it.
+.pl +1
.Pp
If there is an
.Ic alias
@@ -2049,6 +2058,7 @@ Note that this is a special, late occurring, case of
.Ic alias
substitution,
and only allows words to be prepended to the argument list without change.
+.ne 1i
.Ss Signal handling
The shell normally ignores
.Ar quit
diff --git a/bin/csh/csh.c b/bin/csh/csh.c
index 8f70d32..510c68a 100644
--- a/bin/csh/csh.c
+++ b/bin/csh/csh.c
@@ -38,7 +38,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)csh.c 8.2 (Berkeley) 10/12/93";
+static char sccsid[] = "@(#)csh.c 8.4 (Berkeley) 4/29/95";
#endif /* not lint */
#include <sys/types.h>
@@ -116,7 +116,8 @@ main(argc, argv)
register char *tcp;
register int f;
register char **tempv;
- struct sigvec osv;
+ struct sigaction oact;
+ sigset_t sigset;
cshin = stdin;
cshout = stdout;
@@ -266,16 +267,14 @@ main(argc, argv)
* only if we are the login shell.
*/
/* parents interruptibility */
- (void) sigvec(SIGINT, NULL, &osv);
- parintr = (void (*) ()) osv.sv_handler;
- (void) sigvec(SIGTERM, NULL, &osv);
- parterm = (void (*) ()) osv.sv_handler;
+ (void) sigaction(SIGINT, NULL, &oact);
+ parintr = oact.sa_handler;
+ (void) sigaction(SIGTERM, NULL, &oact);
+ parterm = oact.sa_handler;
- if (loginsh) {
- (void) signal(SIGHUP, phup); /* exit processing on HUP */
- (void) signal(SIGXCPU, phup); /* ...and on XCPU */
- (void) signal(SIGXFSZ, phup); /* ...and on XFSZ */
- }
+ (void) signal(SIGHUP, phup); /* exit processing on HUP */
+ (void) signal(SIGXCPU, phup); /* ...and on XCPU */
+ (void) signal(SIGXFSZ, phup); /* ...and on XFSZ */
/*
* Process the arguments.
@@ -450,7 +449,9 @@ main(argc, argv)
if (!quitit) /* Wary! */
(void) signal(SIGQUIT, SIG_IGN);
(void) signal(SIGINT, pintr);
- (void) sigblock(sigmask(SIGINT));
+ sigemptyset(&sigset);
+ sigaddset(&sigset, SIGINT);
+ sigprocmask(SIG_BLOCK, &sigset, NULL);
(void) signal(SIGTERM, SIG_IGN);
if (quitit == 0 && arginp == 0) {
(void) signal(SIGTSTP, SIG_IGN);
@@ -518,7 +519,11 @@ notty:
{
int osetintr = setintr;
sig_t oparintr = parintr;
- sigset_t omask = sigblock(sigmask(SIGINT));
+ sigset_t osigset;
+
+ sigemptyset(&sigset);
+ sigaddset(&sigset, SIGINT);
+ sigprocmask(SIG_BLOCK, &sigset, &osigset);
setintr = 0;
parintr = SIG_IGN; /* Disable onintr */
@@ -531,7 +536,7 @@ notty:
if (loginsh)
(void) srcfile(_PATH_DOTLOGIN, 0, 0);
#endif
- (void) sigsetmask(omask);
+ sigprocmask(SIG_SETMASK, &osigset, NULL);
setintr = osetintr;
parintr = oparintr;
}
@@ -688,7 +693,7 @@ srcunit(unit, onlyown, hflg)
bool otell = cantell;
struct Bin saveB;
- volatile sigset_t omask;
+ sigset_t sigset, osigset;
jmp_buf oldexit;
/* The (few) real local variables */
@@ -719,12 +724,14 @@ srcunit(unit, onlyown, hflg)
*/
insource = 1;
getexit(oldexit);
- omask = 0;
- if (setintr)
- omask = sigblock(sigmask(SIGINT));
+ if (setintr) {
+ sigemptyset(&sigset);
+ sigaddset(&sigset, SIGINT);
+ sigprocmask(SIG_BLOCK, &sigset, &osigset);
+ }
/* Setup the new values of the state stuff saved above */
- bcopy((char *) &B, (char *) &(saveB), sizeof(B));
+ memmove(&saveB, &B, sizeof(B));
fbuf = NULL;
fseekp = feobp = fblocks = 0;
oSHIN = SHIN, SHIN = unit, arginp = 0, onelflg = 0;
@@ -740,14 +747,14 @@ srcunit(unit, onlyown, hflg)
* interrupted.
*/
if (setintr)
- (void) sigsetmask(omask);
+ sigprocmask(SIG_SETMASK, &osigset, NULL);
settell();
if ((my_reenter = setexit()) == 0)
process(0); /* 0 -> blow away on errors */
if (setintr)
- (void) sigsetmask(omask);
+ sigprocmask(SIG_SETMASK, &osigset, NULL);
if (oSHIN >= 0) {
register int i;
@@ -758,7 +765,7 @@ srcunit(unit, onlyown, hflg)
xfree((ptr_t) fbuf);
/* Reset input arena */
- bcopy((char *) &(saveB), (char *) &B, sizeof(B));
+ memmove(&B, &saveB, sizeof(B));
(void) close(SHIN), SHIN = oSHIN;
arginp = oarginp, onelflg = oonelflg;
@@ -807,7 +814,8 @@ rechist()
(void) Strcat(buf, STRsldthist);
}
- if ((fp = creat(short2str(hfile), 0600)) == -1)
+ if ((fp = open(short2str(hfile), O_WRONLY | O_CREAT | O_TRUNC,
+ 0600)) == -1)
return;
oldidfds = didfds;
@@ -899,7 +907,7 @@ int sig;
while ((np = np->p_friends) != pp);
}
}
- _exit(sig);
+ xexit(sig);
}
Char *jobargv[2] = {STRjobs, 0};
@@ -924,11 +932,14 @@ pintr1(wantnl)
bool wantnl;
{
Char **v;
- sigset_t omask;
+ sigset_t sigset, osigset;
- omask = sigblock((sigset_t) 0);
+ sigemptyset(&sigset);
+ sigprocmask(SIG_BLOCK, &sigset, &osigset);
if (setintr) {
- (void) sigsetmask(omask & ~sigmask(SIGINT));
+ sigset = osigset;
+ sigdelset(&sigset, SIGINT);
+ sigprocmask(SIG_SETMASK, &sigset, NULL);
if (pjobs) {
pjobs = 0;
(void) fprintf(cshout, "\n");
@@ -936,7 +947,8 @@ pintr1(wantnl)
stderror(ERR_NAME | ERR_INTR);
}
}
- (void) sigsetmask(omask & ~sigmask(SIGCHLD));
+ sigdelset(&osigset, SIGCHLD);
+ sigprocmask(SIG_SETMASK, &osigset, NULL);
(void) fpurge(cshout);
(void) endpwent();
@@ -982,6 +994,7 @@ process(catch)
{
jmp_buf osetexit;
struct command *t = savet;
+ sigset_t sigset;
savet = NULL;
getexit(osetexit);
@@ -995,8 +1008,11 @@ process(catch)
/*
* Interruptible during interactive reads
*/
- if (setintr)
- (void) sigsetmask(sigblock((sigset_t) 0) & ~sigmask(SIGINT));
+ if (setintr) {
+ sigemptyset(&sigset);
+ sigaddset(&sigset, SIGINT);
+ sigprocmask(SIG_UNBLOCK, &sigset, NULL);
+ }
/*
* For the sake of reset()
@@ -1060,7 +1076,7 @@ process(catch)
* The parser may lose space if interrupted.
*/
if (setintr)
- (void) sigblock(sigmask(SIGINT));
+ sigprocmask(SIG_BLOCK, &sigset, NULL);
/*
* Save input text on the history list if reading in old history, or it
diff --git a/bin/csh/csh.h b/bin/csh/csh.h
index 367b51e..db8ebf9 100644
--- a/bin/csh/csh.h
+++ b/bin/csh/csh.h
@@ -30,7 +30,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)csh.h 8.1 (Berkeley) 5/31/93
+ * @(#)csh.h 8.2 (Berkeley) 4/29/95
*/
/*
@@ -186,8 +186,8 @@ jmp_buf reslab;
#define setexit() (setjmp(reslab))
#define reset() longjmp(reslab, 1)
/* Should use structure assignment here */
-#define getexit(a) bcopy((char *)reslab, ((char *)(a)), sizeof reslab)
-#define resexit(a) bcopy((char *)(a), (char *)reslab, sizeof reslab)
+#define getexit(a) memmove((a), reslab, sizeof reslab)
+#define resexit(a) memmove(reslab, (a), sizeof reslab)
Char *gointr; /* Label for an onintr transfer */
diff --git a/bin/csh/dir.c b/bin/csh/dir.c
index 04efd3f..6416f1a 100644
--- a/bin/csh/dir.c
+++ b/bin/csh/dir.c
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)dir.c 8.1 (Berkeley) 5/31/93";
+static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 4/29/95";
#endif /* not lint */
#include <sys/param.h>
@@ -80,9 +80,9 @@ dinit(hp)
static char *emsg = "csh: Trying to start from \"%s\"\n";
/* Don't believe the login shell home, because it may be a symlink */
- tcp = getwd(path); /* see ngetwd.c for System V version */
+ tcp = getcwd(path, MAXPATHLEN);
if (tcp == NULL || *tcp == '\0') {
- (void) fprintf(csherr, "csh: %s\n", path);
+ (void) fprintf(csherr, "csh: %s\n", strerror(errno));
if (hp && *hp) {
tcp = short2str(hp);
if (chdir(tcp) == -1)
diff --git a/bin/csh/dol.c b/bin/csh/dol.c
index fcd4c65..435eb6b 100644
--- a/bin/csh/dol.c
+++ b/bin/csh/dol.c
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)dol.c 8.1 (Berkeley) 5/31/93";
+static char sccsid[] = "@(#)dol.c 8.2 (Berkeley) 4/29/95";
#endif /* not lint */
#include <sys/types.h>
@@ -846,16 +846,9 @@ heredoc(term)
bool quoted;
char *tmp;
- if (creat(tmp = short2str(shtemp), 0600) < 0)
+ tmp = short2str(shtemp);
+ if (open(tmp, O_RDWR | O_CREAT | O_TRUNC, 0600) < 0)
stderror(ERR_SYSTEM, tmp, strerror(errno));
- (void) close(0);
- if (open(tmp, O_RDWR) < 0) {
- int oerrno = errno;
-
- (void) unlink(tmp);
- errno = oerrno;
- stderror(ERR_SYSTEM, tmp, strerror(errno));
- }
(void) unlink(tmp); /* 0 0 inode! */
Dv[0] = term;
Dv[1] = NULL;
diff --git a/bin/csh/exec.c b/bin/csh/exec.c
index c9799cb..49c04ae 100644
--- a/bin/csh/exec.c
+++ b/bin/csh/exec.c
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)exec.c 8.1 (Berkeley) 5/31/93";
+static char sccsid[] = "@(#)exec.c 8.3 (Berkeley) 5/23/95";
#endif /* not lint */
#include <sys/types.h>
@@ -116,6 +116,7 @@ doexec(v, t)
register bool slash;
register int hashval = 0, hashval1, i;
Char *blk[2];
+ sigset_t sigset;
/*
* Glob the command name. We will search $path even if this does something,
@@ -191,7 +192,8 @@ doexec(v, t)
* We must do this AFTER any possible forking (like `foo` in glob) so that
* this shell can still do subprocesses.
*/
- (void) sigsetmask((sigset_t) 0);
+ sigemptyset(&sigset);
+ sigprocmask(SIG_SETMASK, &sigset, NULL);
/*
* If no path, no words in path, or a / in the filename then restrict the
* command search.
@@ -654,7 +656,7 @@ tellmewhat(lex)
register struct biltins *bptr;
register struct wordent *sp = lex->next;
bool aliased = 0;
- Char *s0, *s1, *s2;
+ Char *s0, *s1, *s2, *cmd;
Char qc;
if (adrof1(sp->word, &aliases)) {
@@ -701,6 +703,8 @@ tellmewhat(lex)
}
}
+ sp->word = cmd = globone(sp->word, G_IGNORE);
+
if ((i = iscommand(strip(sp->word))) != 0) {
register Char **pv;
register struct varent *v;
@@ -715,10 +719,15 @@ tellmewhat(lex)
while (--i)
pv++;
if (pv[0][0] == 0 || eq(pv[0], STRdot)) {
- sp->word = Strspl(STRdotsl, sp->word);
- prlex(cshout, lex);
- xfree((ptr_t) sp->word);
+ if (!slash) {
+ sp->word = Strspl(STRdotsl, sp->word);
+ prlex(cshout, lex);
+ xfree((ptr_t) sp->word);
+ }
+ else
+ prlex(cshout, lex);
sp->word = s0; /* we save and then restore this */
+ xfree((ptr_t) cmd);
return;
}
s1 = Strspl(*pv, STRslash);
@@ -733,4 +742,5 @@ tellmewhat(lex)
(void) fprintf(csherr, "%s: Command not found.\n", vis_str(sp->word));
}
sp->word = s0; /* we save and then restore this */
+ xfree((ptr_t) cmd);
}
diff --git a/bin/csh/file.c b/bin/csh/file.c
index 523844d..3a89d34 100644
--- a/bin/csh/file.c
+++ b/bin/csh/file.c
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)file.c 8.2 (Berkeley) 3/19/94";
+static char sccsid[] = "@(#)file.c 8.4 (Berkeley) 5/6/95";
#endif /* not lint */
#ifdef FILEC
@@ -138,9 +138,11 @@ static void
back_to_col_1()
{
struct termios tty, tty_normal;
- int omask;
+ sigset_t sigset, osigset;
- omask = sigblock(sigmask(SIGINT));
+ sigemptyset(&sigset);
+ sigaddset(&sigset, SIGINT);
+ sigprocmask(SIG_BLOCK, &sigset, &osigset);
(void) tcgetattr(SHOUT, &tty);
tty_normal = tty;
tty.c_iflag &= ~INLCR;
@@ -148,7 +150,7 @@ back_to_col_1()
(void) tcsetattr(SHOUT, TCSANOW, &tty);
(void) write(SHOUT, "\r", 1);
(void) tcsetattr(SHOUT, TCSANOW, &tty_normal);
- (void) sigsetmask(omask);
+ sigprocmask(SIG_SETMASK, &osigset, NULL);
}
/*
@@ -160,10 +162,12 @@ pushback(string)
{
register Char *p;
struct termios tty, tty_normal;
- int omask;
+ sigset_t sigset, osigset;
char c;
- omask = sigblock(sigmask(SIGINT));
+ sigemptyset(&sigset);
+ sigaddset(&sigset, SIGINT);
+ sigprocmask(SIG_BLOCK, &sigset, &osigset);
(void) tcgetattr(SHOUT, &tty);
tty_normal = tty;
tty.c_lflag &= ~(ECHOKE | ECHO | ECHOE | ECHOK | ECHONL | ECHOPRT | ECHOCTL);
@@ -172,7 +176,7 @@ pushback(string)
for (p = string; (c = *p) != '\0'; p++)
(void) ioctl(SHOUT, TIOCSTI, (ioctl_t) & c);
(void) tcsetattr(SHOUT, TCSANOW, &tty_normal);
- (void) sigsetmask(omask);
+ sigprocmask(SIG_SETMASK, &osigset, NULL);
}
/*
@@ -416,12 +420,14 @@ free_items(items)
}
#define FREE_ITEMS(items) { \
- int omask;\
+ sigset_t sigset, osigset;\
\
- omask = sigblock(sigmask(SIGINT));\
+ sigemptyset(&sigset);\
+ sigaddset(&sigset, SIGINT);\
+ sigprocmask(SIG_BLOCK, &sigset, &osigset);\
free_items(items);\
items = NULL;\
- (void) sigsetmask(omask);\
+ sigprocmask(SIG_SETMASK, &osigset, NULL);\
}
/*
diff --git a/bin/csh/func.c b/bin/csh/func.c
index 82664c6..8d02479 100644
--- a/bin/csh/func.c
+++ b/bin/csh/func.c
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)func.c 8.1 (Berkeley) 5/31/93";
+static char sccsid[] = "@(#)func.c 8.2 (Berkeley) 3/22/95";
#endif /* not lint */
#include <sys/types.h>
@@ -133,6 +133,7 @@ doonintr(v, t)
{
register Char *cp;
register Char *vv = v[1];
+ sigset_t sigset;
if (parintr == SIG_IGN)
return;
@@ -142,9 +143,11 @@ doonintr(v, t)
gointr = 0;
xfree((ptr_t) cp);
if (vv == 0) {
- if (setintr)
- (void) sigblock(sigmask(SIGINT));
- else
+ if (setintr) {
+ sigemptyset(&sigset);
+ sigaddset(&sigset, SIGINT);
+ sigprocmask(SIG_BLOCK, &sigset, NULL);
+ } else
(void) signal(SIGINT, SIG_DFL);
gointr = 0;
}
@@ -503,13 +506,18 @@ dowhile(v, t)
static void
preread()
{
+ sigset_t sigset;
+
whyles->w_end.type = I_SEEK;
- if (setintr)
- (void) sigsetmask(sigblock((sigset_t) 0) & ~sigmask(SIGINT));
+ if (setintr) {
+ sigemptyset(&sigset);
+ sigaddset(&sigset, SIGINT);
+ sigprocmask(SIG_UNBLOCK, &sigset, NULL);
+ }
search(T_BREAK, 0, NULL); /* read the expression in */
if (setintr)
- (void) sigblock(sigmask(SIGINT));
+ sigprocmask(SIG_BLOCK, &sigset, NULL);
btell(&whyles->w_end);
}
@@ -563,21 +571,24 @@ dorepeat(v, kp)
struct command *kp;
{
register int i;
- register sigset_t omask = 0;
+ sigset_t sigset;
i = getn(v[1]);
- if (setintr)
- omask = sigblock(sigmask(SIGINT)) & ~sigmask(SIGINT);
+ if (setintr) {
+ sigemptyset(&sigset);
+ sigaddset(&sigset, SIGINT);
+ sigprocmask(SIG_BLOCK, &sigset, NULL);
+ }
lshift(v, 2);
while (i > 0) {
if (setintr)
- (void) sigsetmask(omask);
+ sigprocmask(SIG_UNBLOCK, &sigset, NULL);
reexecute(kp);
--i;
}
donefds();
if (setintr)
- (void) sigsetmask(omask);
+ sigprocmask(SIG_UNBLOCK, &sigset, NULL);
}
void
@@ -903,9 +914,13 @@ xecho(sep, v)
{
register Char *cp;
int nonl = 0;
+ sigset_t sigset;
- if (setintr)
- (void) sigsetmask(sigblock((sigset_t) 0) & ~sigmask(SIGINT));
+ if (setintr) {
+ sigemptyset(&sigset);
+ sigaddset(&sigset, SIGINT);
+ sigprocmask(SIG_UNBLOCK, &sigset, NULL);
+ }
v++;
if (*v == 0)
return;
@@ -935,7 +950,7 @@ xecho(sep, v)
else
(void) fflush(cshout);
if (setintr)
- (void) sigblock(sigmask(SIGINT));
+ sigprocmask(SIG_BLOCK, &sigset, NULL);
if (gargv)
blkfree(gargv), gargv = 0;
}
@@ -947,13 +962,17 @@ dosetenv(v, t)
struct command *t;
{
Char *vp, *lp;
+ sigset_t sigset;
v++;
if ((vp = *v++) == 0) {
register Char **ep;
- if (setintr)
- (void) sigsetmask(sigblock((sigset_t) 0) & ~sigmask(SIGINT));
+ if (setintr) {
+ sigemptyset(&sigset);
+ sigaddset(&sigset, SIGINT);
+ sigprocmask(SIG_UNBLOCK, &sigset, NULL);
+ }
for (ep = STR_environ; *ep; ep++)
(void) fprintf(cshout, "%s\n", vis_str(*ep));
return;
diff --git a/bin/csh/hist.c b/bin/csh/hist.c
index d55a416..673cf54 100644
--- a/bin/csh/hist.c
+++ b/bin/csh/hist.c
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)hist.c 8.1 (Berkeley) 5/31/93";
+static char sccsid[] = "@(#)hist.c 8.2 (Berkeley) 3/22/95";
#endif /* not lint */
#include <sys/types.h>
@@ -121,11 +121,15 @@ dohist(v, t)
struct command *t;
{
int n, rflg = 0, hflg = 0;
+ sigset_t sigset;
if (getn(value(STRhistory)) == 0)
return;
- if (setintr)
- (void) sigsetmask(sigblock((sigset_t) 0) & ~sigmask(SIGINT));
+ if (setintr) {
+ sigemptyset(&sigset);
+ sigaddset(&sigset, SIGINT);
+ sigprocmask(SIG_UNBLOCK, &sigset, NULL);
+ }
while (*++v && **v == '-') {
Char *vp = *v;
diff --git a/bin/csh/lex.c b/bin/csh/lex.c
index 21f50d3..36791f9 100644
--- a/bin/csh/lex.c
+++ b/bin/csh/lex.c
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)lex.c 8.1 (Berkeley) 5/31/93";
+static char sccsid[] = "@(#)lex.c 8.2 (Berkeley) 4/29/95";
#endif /* not lint */
#include <sys/types.h>
@@ -1503,7 +1503,7 @@ again:
goto again;
}
if (c > 0)
- bcopy(ttyline, fbuf[buf] + off, c * sizeof(Char));
+ memmove(fbuf[buf] + off, ttyline, c * sizeof(Char));
numleft = 0;
}
else {
diff --git a/bin/csh/proc.c b/bin/csh/proc.c
index 8a85fdc..6bba00a 100644
--- a/bin/csh/proc.c
+++ b/bin/csh/proc.c
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)proc.c 8.1 (Berkeley) 5/31/93";
+static char sccsid[] = "@(#)proc.c 8.2 (Berkeley) 3/22/95";
#endif /* not lint */
#include <sys/types.h>
@@ -201,17 +201,19 @@ pnote()
{
register struct process *pp;
int flags;
- sigset_t omask;
+ sigset_t sigset, osigset;
neednote = 0;
+ sigemptyset(&sigset);
+ sigaddset(&sigset, SIGCHLD);
for (pp = proclist.p_next; pp != NULL; pp = pp->p_next) {
if (pp->p_flags & PNEEDNOTE) {
- omask = sigblock(sigmask(SIGCHLD));
+ sigprocmask(SIG_BLOCK, &sigset, &osigset);
pp->p_flags &= ~PNEEDNOTE;
flags = pprint(pp, NUMBER | NAME | REASON);
if ((flags & (PRUNNING | PSTOPPED)) == 0)
pflush(pp);
- (void) sigsetmask(omask);
+ sigprocmask(SIG_SETMASK, &osigset, NULL);
}
}
}
@@ -224,12 +226,14 @@ void
pwait()
{
register struct process *fp, *pp;
- sigset_t omask;
+ sigset_t sigset, osigset;
/*
* Here's where dead procs get flushed.
*/
- omask = sigblock(sigmask(SIGCHLD));
+ sigemptyset(&sigset);
+ sigaddset(&sigset, SIGCHLD);
+ sigprocmask(SIG_BLOCK, &sigset, &osigset);
for (pp = (fp = &proclist)->p_next; pp != NULL; pp = (fp = pp)->p_next)
if (pp->p_pid == 0) {
fp->p_next = pp->p_next;
@@ -240,7 +244,7 @@ pwait()
xfree((ptr_t) pp);
pp = fp;
}
- (void) sigsetmask(omask);
+ sigprocmask(SIG_SETMASK, &osigset, NULL);
pjwait(pcurrjob);
}
@@ -255,7 +259,7 @@ pjwait(pp)
{
register struct process *fp;
int jobflags, reason;
- sigset_t omask;
+ sigset_t sigset, osigset;
while (pp->p_pid != pp->p_jobid)
pp = pp->p_friends;
@@ -270,9 +274,13 @@ pjwait(pp)
* target process, or any of its friends, are running
*/
fp = pp;
- omask = sigblock(sigmask(SIGCHLD));
+ sigemptyset(&sigset);
+ sigaddset(&sigset, SIGCHLD);
+ sigprocmask(SIG_BLOCK, &sigset, &osigset);
for (;;) {
- (void) sigblock(sigmask(SIGCHLD));
+ sigemptyset(&sigset);
+ sigaddset(&sigset, SIGCHLD);
+ sigprocmask(SIG_BLOCK, &sigset, NULL);
jobflags = 0;
do
jobflags |= fp->p_flags;
@@ -280,12 +288,14 @@ pjwait(pp)
if ((jobflags & PRUNNING) == 0)
break;
#ifdef JOBDEBUG
- (void) fprintf(csherr, "starting to sigpause for SIGCHLD on %d\n",
+ (void) fprintf(csherr, "starting to sigsuspend for SIGCHLD on %d\n",
fp->p_pid);
#endif /* JOBDEBUG */
- (void) sigpause(omask & ~sigmask(SIGCHLD));
+ sigset = osigset;
+ sigdelset(&sigset, SIGCHLD);
+ sigsuspend(&sigset);
}
- (void) sigsetmask(omask);
+ sigprocmask(SIG_SETMASK, &osigset, NULL);
if (tpgrp > 0) /* get tty back */
(void) tcsetpgrp(FSHTTY, tpgrp);
if ((jobflags & (PSIGNALED | PSTOPPED | PTIME)) ||
@@ -344,18 +354,21 @@ dowait(v, t)
struct command *t;
{
register struct process *pp;
- sigset_t omask;
+ sigset_t sigset, osigset;
pjobs++;
- omask = sigblock(sigmask(SIGCHLD));
+ sigemptyset(&sigset);
+ sigaddset(&sigset, SIGCHLD);
+ sigprocmask(SIG_BLOCK, &sigset, &osigset);
loop:
for (pp = proclist.p_next; pp; pp = pp->p_next)
if (pp->p_pid && /* pp->p_pid == pp->p_jobid && */
pp->p_flags & PRUNNING) {
- (void) sigpause((sigset_t) 0);
+ sigemptyset(&sigset);
+ sigsuspend(&sigset);
goto loop;
}
- (void) sigsetmask(omask);
+ sigprocmask(SIG_SETMASK, &osigset, NULL);
pjobs = 0;
}
@@ -999,13 +1012,14 @@ pkill(v, signum)
register struct process *pp, *np;
register int jobflags = 0;
int pid, err1 = 0;
- sigset_t omask;
+ sigset_t sigset;
Char *cp;
- omask = sigmask(SIGCHLD);
+ sigemptyset(&sigset);
+ sigaddset(&sigset, SIGCHLD);
if (setintr)
- omask |= sigmask(SIGINT);
- omask = sigblock(omask) & ~omask;
+ sigaddset(&sigset, SIGINT);
+ sigprocmask(SIG_BLOCK, &sigset, NULL);
gflag = 0, tglob(v);
if (gflag) {
v = globall(v);
@@ -1069,7 +1083,7 @@ cont:
}
if (gargv)
blkfree(gargv), gargv = 0;
- (void) sigsetmask(omask);
+ sigprocmask(SIG_UNBLOCK, &sigset, NULL);
if (err1)
stderror(ERR_SILENT);
}
@@ -1083,10 +1097,12 @@ pstart(pp, foregnd)
int foregnd;
{
register struct process *np;
- sigset_t omask;
+ sigset_t sigset, osigset;
long jobflags = 0;
- omask = sigblock(sigmask(SIGCHLD));
+ sigemptyset(&sigset);
+ sigaddset(&sigset, SIGCHLD);
+ sigprocmask(SIG_BLOCK, &sigset, &osigset);
np = pp;
do {
jobflags |= np->p_flags;
@@ -1106,7 +1122,7 @@ pstart(pp, foregnd)
(void) tcsetpgrp(FSHTTY, pp->p_jobid);
if (jobflags & PSTOPPED)
(void) killpg((pid_t) pp->p_jobid, SIGCONT);
- (void) sigsetmask(omask);
+ sigprocmask(SIG_SETMASK, &osigset, NULL);
}
void
@@ -1229,7 +1245,7 @@ pfork(t, wanttty)
register int pid;
bool ignint = 0;
int pgrp;
- sigset_t omask;
+ sigset_t sigset, osigset;
/*
* A child will be uninterruptible only under very special conditions.
@@ -1250,12 +1266,14 @@ pfork(t, wanttty)
/*
* Hold SIGCHLD until we have the process installed in our table.
*/
- omask = sigblock(sigmask(SIGCHLD));
+ sigemptyset(&sigset);
+ sigaddset(&sigset, SIGCHLD);
+ sigprocmask(SIG_BLOCK, &sigset, &osigset);
while ((pid = fork()) < 0)
if (setintr == 0)
(void) sleep(FORKSLEEP);
else {
- (void) sigsetmask(omask);
+ sigprocmask(SIG_SETMASK, &osigset, NULL);
stderror(ERR_NOPROC);
}
if (pid == 0) {
@@ -1299,7 +1317,7 @@ pfork(t, wanttty)
if (wanttty >= 0)
(void) setpgid(pid, pcurrjob ? pcurrjob->p_jobid : pid);
palloc(pid, t);
- (void) sigsetmask(omask);
+ sigprocmask(SIG_SETMASK, &osigset, NULL);
}
return (pid);
@@ -1326,14 +1344,19 @@ void
pgetty(wanttty, pgrp)
int wanttty, pgrp;
{
- sigset_t omask = 0;
+ sigset_t sigset, osigset;
/*
* christos: I am blocking the tty signals till I've set things
* correctly....
*/
- if (wanttty > 0)
- omask = sigblock(sigmask(SIGTSTP)|sigmask(SIGTTIN)|sigmask(SIGTTOU));
+ if (wanttty > 0) {
+ sigemptyset(&sigset);
+ sigaddset(&sigset, SIGTSTP);
+ sigaddset(&sigset, SIGTTIN);
+ sigaddset(&sigset, SIGTTOU);
+ sigprocmask(SIG_BLOCK, &sigset, &osigset);
+ }
/*
* From: Michael Schroeder <mlschroe@immd4.informatik.uni-erlangen.de>
* Don't check for tpgrp >= 0 so even non-interactive shells give
@@ -1348,7 +1371,7 @@ pgetty(wanttty, pgrp)
if (wanttty > 0) {
(void) tcsetpgrp(FSHTTY, pgrp);
- (void) sigsetmask(omask);
+ sigprocmask(SIG_SETMASK, &osigset, NULL);
}
if (tpgrp > 0)
diff --git a/bin/csh/sem.c b/bin/csh/sem.c
index 584d3fb..775ad35 100644
--- a/bin/csh/sem.c
+++ b/bin/csh/sem.c
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)sem.c 8.1 (Berkeley) 5/31/93";
+static char sccsid[] = "@(#)sem.c 8.3 (Berkeley) 4/29/95";
#endif /* not lint */
#include <sys/param.h>
@@ -67,10 +67,11 @@ execute(t, wanttty, pipein, pipeout)
struct biltins *bifunc;
int pid = 0;
int pv[2];
+ sigset_t sigset;
- static sigset_t csigmask;
+ static sigset_t csigset;
- static sigset_t ocsigmask;
+ static sigset_t ocsigset;
static int onosigchld = 0;
static int nosigchld = 0;
@@ -208,13 +209,15 @@ execute(t, wanttty, pipein, pipeout)
* not die before we can set the process group
*/
if (wanttty >= 0 && !nosigchld) {
- csigmask = sigblock(sigmask(SIGCHLD));
+ sigemptyset(&sigset);
+ sigaddset(&sigset, SIGCHLD);
+ sigprocmask(SIG_BLOCK, &sigset, &csigset);
nosigchld = 1;
}
pid = pfork(t, wanttty);
if (pid == 0 && nosigchld) {
- (void) sigsetmask(csigmask);
+ sigprocmask(SIG_SETMASK, &csigset, NULL);
nosigchld = 0;
}
else if (pid != 0 && (t->t_dflg & F_AMPERSAND))
@@ -224,21 +227,26 @@ execute(t, wanttty, pipein, pipeout)
else {
int ochild, osetintr, ohaderr, odidfds;
int oSHIN, oSHOUT, oSHERR, oOLDSTD, otpgrp;
- sigset_t omask;
+ sigset_t osigset;
/*
* Prepare for the vfork by saving everything that the child
* corrupts before it exec's. Note that in some signal
* implementations which keep the signal info in user space
* (e.g. Sun's) it will also be necessary to save and restore
- * the current sigvec's for the signals the child touches
+ * the current sigaction's for the signals the child touches
* before it exec's.
*/
if (wanttty >= 0 && !nosigchld && !noexec) {
- csigmask = sigblock(sigmask(SIGCHLD));
+ sigemptyset(&sigset);
+ sigaddset(&sigset, SIGCHLD);
+ sigprocmask(SIG_BLOCK, &sigset, &csigset);
nosigchld = 1;
}
- omask = sigblock(sigmask(SIGCHLD) | sigmask(SIGINT));
+ sigemptyset(&sigset);
+ sigaddset(&sigset, SIGCHLD);
+ sigaddset(&sigset, SIGINT);
+ sigprocmask(SIG_BLOCK, &sigset, &osigset);
ochild = child;
osetintr = setintr;
ohaderr = haderr;
@@ -248,7 +256,7 @@ execute(t, wanttty, pipein, pipeout)
oSHERR = SHERR;
oOLDSTD = OLDSTD;
otpgrp = tpgrp;
- ocsigmask = csigmask;
+ ocsigset = csigset;
onosigchld = nosigchld;
Vsav = Vdp = 0;
Vexpath = 0;
@@ -256,7 +264,7 @@ execute(t, wanttty, pipein, pipeout)
pid = vfork();
if (pid < 0) {
- (void) sigsetmask(omask);
+ sigprocmask(SIG_SETMASK, &osigset, NULL);
stderror(ERR_NOPROC);
}
forked++;
@@ -270,7 +278,7 @@ execute(t, wanttty, pipein, pipeout)
SHERR = oSHERR;
OLDSTD = oOLDSTD;
tpgrp = otpgrp;
- csigmask = ocsigmask;
+ csigset = ocsigset;
nosigchld = onosigchld;
xfree((ptr_t) Vsav);
@@ -283,7 +291,7 @@ execute(t, wanttty, pipein, pipeout)
Vt = 0;
/* this is from pfork() */
palloc(pid, t);
- (void) sigsetmask(omask);
+ sigprocmask(SIG_SETMASK, &osigset, NULL);
}
else { /* child */
/* this is from pfork() */
@@ -291,7 +299,7 @@ execute(t, wanttty, pipein, pipeout)
bool ignint = 0;
if (nosigchld) {
- (void) sigsetmask(csigmask);
+ sigprocmask(SIG_SETMASK, &csigset, NULL);
nosigchld = 0;
}
@@ -348,7 +356,7 @@ execute(t, wanttty, pipein, pipeout)
}
if ((t->t_dflg & F_PIPEOUT) == 0) {
if (nosigchld) {
- (void) sigsetmask(csigmask);
+ sigprocmask(SIG_SETMASK, &csigset, NULL);
nosigchld = 0;
}
if ((t->t_dflg & F_AMPERSAND) == 0)
@@ -590,7 +598,7 @@ doio(t, pipein, pipeout)
stderror(ERR_SYSTEM, tmp, strerror(errno));
chkclob(tmp);
}
- if ((fd = creat(tmp, 0666)) < 0)
+ if ((fd = open(tmp, O_WRONLY | O_CREAT | O_TRUNC, 0666)) < 0)
stderror(ERR_SYSTEM, tmp, strerror(errno));
}
(void) dmove(fd, 1);
diff --git a/bin/csh/set.c b/bin/csh/set.c
index b7b7ff1..1192163 100644
--- a/bin/csh/set.c
+++ b/bin/csh/set.c
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)set.c 8.1 (Berkeley) 5/31/93";
+static char sccsid[] = "@(#)set.c 8.2 (Berkeley) 3/22/95";
#endif /* not lint */
#include <sys/types.h>
@@ -813,9 +813,13 @@ plist(p)
{
register struct varent *c;
register len;
+ sigset_t sigset;
- if (setintr)
- (void) sigsetmask(sigblock((sigset_t) 0) & ~sigmask(SIGINT));
+ if (setintr) {
+ sigemptyset(&sigset);
+ sigaddset(&sigset, SIGINT);
+ sigprocmask(SIG_UNBLOCK, &sigset, NULL);
+ }
for (;;) {
while (p->v_left)
diff --git a/bin/date/date.1 b/bin/date/date.1
index 0eb6c7b..3b26b85 100644
--- a/bin/date/date.1
+++ b/bin/date/date.1
@@ -32,9 +32,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)date.1 8.2 (Berkeley) 11/17/93
+.\" @(#)date.1 8.3 (Berkeley) 4/28/95
.\"
-.Dd November 17, 1993
+.Dd April 28, 1995
.Dt DATE 1
.Os
.Sh NAME
@@ -104,9 +104,11 @@ The format string may contain any of the conversion specifications described
in the
.Xr strftime 3
manual page, as well as any arbitrary text.
+A <newline> character is always output after the characters specified by
+the format string.
The format string for the default display is:
.Bd -literal -offset indent
-``%a %b %e %H:%M:%S %Z n''.
+``%a %b %e %H:%M:%S %Z %Y''.
.Ed
.Pp
If an operand does not have a leading plus sign, it is interpreted as
@@ -136,7 +138,7 @@ and years are handled automatically.
.Sh EXAMPLES
The command:
.Bd -literal -offset indent
-date ``+DATE: %m/%d/%y%nTIME: %H:%M:0n''
+date ``+DATE: %m/%d/%y%nTIME: %H:%M:%S''
.Ed
.Pp
will display:
diff --git a/bin/date/date.c b/bin/date/date.c
index 3563bac..6d338b5 100644
--- a/bin/date/date.c
+++ b/bin/date/date.c
@@ -38,7 +38,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)date.c 8.1 (Berkeley) 5/31/93";
+static char sccsid[] = "@(#)date.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
#include <sys/param.h>
@@ -77,7 +77,7 @@ main(argc, argv)
tz.tz_dsttime = tz.tz_minuteswest = 0;
rflag = 0;
- while ((ch = getopt(argc, argv, "d:nr:ut:")) != EOF)
+ while ((ch = getopt(argc, argv, "d:nr:ut:")) != -1)
switch((char)ch) {
case 'd': /* daylight savings time */
tz.tz_dsttime = atoi(optarg) ? 1 : 0;
@@ -116,7 +116,7 @@ main(argc, argv)
if (!rflag && time(&tval) == -1)
err(1, "time");
- format = "%a %b %e %H:%M:%S %Z %Y\n";
+ format = "%a %b %e %H:%M:%S %Z %Y";
/* allow the operands in any order */
if (*argv && **argv == '+') {
@@ -133,7 +133,7 @@ main(argc, argv)
format = *argv + 1;
(void)strftime(buf, sizeof(buf), format, localtime(&tval));
- (void)printf("%s", buf);
+ (void)printf("%s\n", buf);
exit(retval);
}
diff --git a/bin/date/netdate.c b/bin/date/netdate.c
index 2dca0f7..ef254c6 100644
--- a/bin/date/netdate.c
+++ b/bin/date/netdate.c
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)netdate.c 8.1 (Berkeley) 5/31/93";
+static char sccsid[] = "@(#)netdate.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
#include <sys/param.h>
@@ -82,6 +82,7 @@ netsettime(tval)
return (retval = 2);
}
+ memset(&dest, 0, sizeof(dest));
dest.sin_port = sp->s_port;
dest.sin_family = AF_INET;
dest.sin_addr.s_addr = htonl((u_long)INADDR_ANY);
diff --git a/bin/hostname/hostname.1 b/bin/hostname/hostname.1
index 98bcb7e..aa7ea54 100644
--- a/bin/hostname/hostname.1
+++ b/bin/hostname/hostname.1
@@ -29,9 +29,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)hostname.1 8.1 (Berkeley) 5/31/93
+.\" @(#)hostname.1 8.2 (Berkeley) 4/28/95
.\"
-.Dd May 31, 1993
+.Dd April 28, 1995
.Dt HOSTNAME 1
.Os BSD 4.2
.Sh NAME
@@ -40,7 +40,7 @@
.Sh SYNOPSIS
.Nm hostname
.Op Fl s
-.Op Ar nameofhost
+.Op Ar name-of-host
.Sh DESCRIPTION
.Nm Hostname
prints the name of the current host. The super-user can
@@ -57,7 +57,8 @@ Trims off any domain information from the printed
name.
.El
.Sh SEE ALSO
-.Xr gethostname 2
+.Xr gethostname 2 ,
+.Xr sethostname 2
.Sh HISTORY
The
.Nm hostname
diff --git a/bin/hostname/hostname.c b/bin/hostname/hostname.c
index afee46a..cbe654c 100644
--- a/bin/hostname/hostname.c
+++ b/bin/hostname/hostname.c
@@ -38,7 +38,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)hostname.c 8.1 (Berkeley) 5/31/93";
+static char sccsid[] = "@(#)hostname.c 8.2 (Berkeley) 4/28/95";
#endif /* not lint */
#include <sys/param.h>
@@ -49,26 +49,25 @@ static char sccsid[] = "@(#)hostname.c 8.1 (Berkeley) 5/31/93";
#include <string.h>
#include <unistd.h>
+void usage __P((void));
+
int
main(argc,argv)
int argc;
char *argv[];
{
- extern int optind;
int ch, sflag;
char *p, hostname[MAXHOSTNAMELEN];
sflag = 0;
- while ((ch = getopt(argc, argv, "s")) != EOF)
+ while ((ch = getopt(argc, argv, "s")) != -1)
switch (ch) {
case 's':
sflag = 1;
break;
case '?':
default:
- (void)fprintf(stderr,
- "usage: hostname [-s] [hostname]\n");
- exit(1);
+ usage();
}
argc -= optind;
argv += optind;
@@ -85,3 +84,11 @@ main(argc,argv)
}
exit(0);
}
+
+void
+usage()
+{
+
+ (void)fprintf(stderr, "usage: hostname [-s] [hostname]\n");
+ exit(1);
+}
diff --git a/bin/kill/kill.1 b/bin/kill/kill.1
index bffef49..66779b7 100644
--- a/bin/kill/kill.1
+++ b/bin/kill/kill.1
@@ -32,9 +32,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)kill.1 8.1 (Berkeley) 5/31/93
+.\" @(#)kill.1 8.2 (Berkeley) 4/28/95
.\"
-.Dd May 31, 1993
+.Dd April 28, 1995
.Dt KILL 1
.Os
.Sh NAME
@@ -42,19 +42,22 @@
.Nd terminate or signal a process
.Sh SYNOPSIS
.Nm kill
-.Op Fl signal_name
+.Op Fl s Ar signal_name
.Ar pid
\&...
.Nm kill
-.Op Fl signal_number
+.Fl l
+.Op Ar exit_status
+.Nm kill
+.Fl signal_name
.Ar pid
\&...
.Nm kill
-.Op Fl l
+.Fl signal_number
+.Ar pid
+\&...
.Sh DESCRIPTION
-The kill utility sends the
-.Dv TERM
-signal to the processes specified
+The kill utility sends a signal to the processes specified
by the pid operand(s).
.Pp
Only the super-user may send signals to other users' processes.
@@ -62,35 +65,48 @@ Only the super-user may send signals to other users' processes.
The options are as follows:
.Pp
.Bl -tag -width Ds
-.It Fl l
-List the signal names.
+.It Fl s Ar signal_name
+A symbolic signal name specifying the signal to be sent instead of the
+default
+.Dv TERM .
+.It Fl l Op Ar exit_status
+If no operand is given, list the signal names; otherwise, write
+the signal name corresponding to
+.Ar exit_status .
.It Fl signal_name
A symbolic signal name specifying the signal to be sent instead of the
default
.Dv TERM .
-The
-.Fl l
-option displays the signal names.
.It Fl signal_number
A non-negative decimal integer, specifying the signal to be sent instead
of the default
.Dv TERM .
.El
.Pp
+The following pids have special meanings:
+.Bl -tag -width Ds -compact
+.It -1
+If superuser, broadcast the signal to all processes; otherwise broadcast
+to all processes belonging to the user.
+.El
+.Pp
Some of the more commonly used signals:
-.Bd -ragged -offset indent -compact
-.Bl -column XXX TERM
-.It -1 -1 (super-user broadcast to all processes, or user broadcast
-to user's processes)
-.It 0 0 (sh(1) only, signals all members of process group)
-.It 2 INT (interrupt)
-.It 3 QUIT (quit)
-.It 6 ABRT (abort)
-.It 9 KILL (non-catchable, non-ignorable kill)
-.It 14 ALRM (alarm clock)
-.It 15 TERM (software termination signal)
+.Bl -tag -width Ds -compact
+.It 1
+HUP (hang up)
+.It 2
+INT (interrupt)
+.It 3
+QUIT (quit)
+.It 6
+ABRT (abort)
+.It 9
+KILL (non-catchable, non-ignorable kill)
+.It 14
+ALRM (alarm clock)
+.It 15
+TERM (software termination signal)
.El
-.Ed
.Pp
.Nm Kill
is a built-in to
@@ -107,6 +123,12 @@ for details.
.Xr ps 1 ,
.Xr kill 2 ,
.Xr sigvec 2
+.Sh STANDARDS
+The
+.Nm kill
+function is expected to be
+.St -p1003.2
+compatible.
.Sh HISTORY
A
.Nm kill
diff --git a/bin/kill/kill.c b/bin/kill/kill.c
index 00daeaf..a3316a4 100644
--- a/bin/kill/kill.c
+++ b/bin/kill/kill.c
@@ -38,7 +38,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)kill.c 8.3 (Berkeley) 4/2/94";
+static char sccsid[] = "@(#)kill.c 8.4 (Berkeley) 4/28/95";
#endif /* not lint */
#include <ctype.h>
@@ -50,7 +50,8 @@ static char sccsid[] = "@(#)kill.c 8.3 (Berkeley) 4/2/94";
#include <string.h>
void nosig __P((char *));
-void printsig __P((FILE *));
+void printsignals __P((FILE *));
+int signame_to_signum __P((char *));
void usage __P((void));
int
@@ -65,39 +66,62 @@ main(argc, argv)
if (argc < 2)
usage();
- if (!strcmp(*++argv, "-l")) {
- printsig(stdout);
+ numsig = SIGTERM;
+
+ argc--, argv++;
+ if (!strcmp(*argv, "-l")) {
+ argc--, argv++;
+ if (argc > 1)
+ usage();
+ if (argc == 1) {
+ if (!isdigit(**argv))
+ usage();
+ numsig = strtol(*argv, &ep, 10);
+ if (!*argv || *ep)
+ errx(1, "illegal signal number: %s", *argv);
+ if (numsig >= 128)
+ numsig -= 128;
+ if (numsig <= 0 || numsig >= NSIG)
+ nosig(*argv);
+ printf("%s\n", sys_signame[numsig]);
+ exit(0);
+ }
+ printsignals(stdout);
exit(0);
}
- numsig = SIGTERM;
- if (**argv == '-') {
+ if (!strcmp(*argv, "-s")) {
+ argc--, argv++;
+ if (argc < 1) {
+ warnx("option requires an argument -- s");
+ usage();
+ }
+ if (strcmp(*argv, "0")) {
+ if ((numsig = signame_to_signum(*argv)) < 0)
+ nosig(*argv);
+ } else
+ numsig = 0;
+ argc--, argv++;
+ } else if (**argv == '-') {
++*argv;
if (isalpha(**argv)) {
- if (!strncasecmp(*argv, "sig", 3))
- *argv += 3;
- for (numsig = NSIG, p = sys_signame + 1; --numsig; ++p)
- if (!strcasecmp(*p, *argv)) {
- numsig = p - sys_signame;
- break;
- }
- if (!numsig)
+ if ((numsig = signame_to_signum(*argv)) < 0)
nosig(*argv);
} else if (isdigit(**argv)) {
numsig = strtol(*argv, &ep, 10);
if (!*argv || *ep)
errx(1, "illegal signal number: %s", *argv);
- if (numsig <= 0 || numsig > NSIG)
+ if (numsig <= 0 || numsig >= NSIG)
nosig(*argv);
} else
nosig(*argv);
- ++argv;
+ argc--, argv++;
}
- if (!*argv)
+ if (argc == 0)
usage();
- for (errors = 0; *argv; ++argv) {
+ for (errors = 0; argc; argc--, argv++) {
pid = strtol(*argv, &ep, 10);
if (!*argv || *ep) {
warnx("illegal process id: %s", *argv);
@@ -107,38 +131,57 @@ main(argc, argv)
errors = 1;
}
}
+
exit(errors);
}
+int
+signame_to_signum(sig)
+ char *sig;
+{
+ int n;
+
+ if (!strncasecmp(sig, "sig", 3))
+ sig += 3;
+ for (n = 1; n < NSIG; n++) {
+ if (!strcasecmp(sys_signame[n], sig))
+ return (n);
+ }
+ return (-1);
+}
+
void
nosig(name)
char *name;
{
warnx("unknown signal %s; valid signals:", name);
- printsig(stderr);
+ printsignals(stderr);
exit(1);
}
void
-printsig(fp)
+printsignals(fp)
FILE *fp;
{
- const char *const *p;
- int cnt;
+ int n;
- for (cnt = NSIG, p = sys_signame + 1; --cnt; ++p) {
- (void)fprintf(fp, "%s ", *p);
- if (cnt == NSIG / 2)
+ for (n = 1; n < NSIG; n++) {
+ (void)fprintf(fp, "%s", sys_signame[n]);
+ if (n == (NSIG / 2) || n == (NSIG - 1))
(void)fprintf(fp, "\n");
+ else
+ (void)fprintf(fp, " ");
}
- (void)fprintf(fp, "\n");
}
void
usage()
{
- (void)fprintf(stderr, "usage: kill [-l] [-sig] pid ...\n");
+ (void)fprintf(stderr, "usage: kill [-s signal_name] pid ...\n");
+ (void)fprintf(stderr, " kill -l [exit_status]\n");
+ (void)fprintf(stderr, " kill -signal_name pid ...\n");
+ (void)fprintf(stderr, " kill -signal_number pid ...\n");
exit(1);
}
diff --git a/bin/ls/ls.1 b/bin/ls/ls.1
index cb45555..6f5f58f 100644
--- a/bin/ls/ls.1
+++ b/bin/ls/ls.1
@@ -32,9 +32,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)ls.1 8.6 (Berkeley) 4/18/94
+.\" @(#)ls.1 8.7 (Berkeley) 7/29/94
.\"
-.Dd April 18, 1994
+.Dd July 29, 1994
.Dt LS 1
.Os
.Sh NAME
@@ -42,7 +42,7 @@
.Nd list directory contents
.Sh SYNOPSIS
.Nm ls
-.Op Fl ACFLRTacdfiloqrstu1
+.Op Fl ACFLRTWacdfiloqrstu1
.Op Ar file ...
.Sh DESCRIPTION
For each operand that names a
@@ -81,7 +81,8 @@ Force multi-column output; this is the default when output is to a terminal.
Display a slash (/) immediately after each pathname
that is a directory, an asterisk (*) after each that is
executable,
-and an at sign (@) after each symbolic link.
+an at sign (@) after each symbolic link,
+and a percent sign (%) after each whiteout.
.\" and a vertical bar (|) after each that is a
.\" .Tn FIFO .
.It Fl L
@@ -92,6 +93,8 @@ Recursively list subdirectories encountered.
.It Fl T
Display complete time information for the file, including
month, day, hour, minute, second, and year.
+.It Fl W
+Display whiteouts when scanning directories.
.It Fl a
Include directory entries whose names begin with a
dot (.).
@@ -213,6 +216,8 @@ Symbolic link.
Socket link.
.\" .It Sy p
.\" .Tn FIFO .
+.It Sy w
+Whiteout.
.It Sy \-
Regular file.
.El
diff --git a/bin/ls/ls.c b/bin/ls/ls.c
index 1cea616..18ac946 100644
--- a/bin/ls/ls.c
+++ b/bin/ls/ls.c
@@ -41,7 +41,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)ls.c 8.5 (Berkeley) 4/2/94";
+static char sccsid[] = "@(#)ls.c 8.7 (Berkeley) 8/5/94";
#endif /* not lint */
#include <sys/types.h>
@@ -90,6 +90,7 @@ int f_statustime; /* use time of last mode change */
int f_dirname; /* if precede with directory name */
int f_timesort; /* sort by time vice name */
int f_type; /* add type character for non-regular files */
+int f_whiteout; /* show whiteout entries */
int
main(argc, argv)
@@ -119,7 +120,7 @@ main(argc, argv)
f_listdot = 1;
fts_options = FTS_PHYSICAL;
- while ((ch = getopt(argc, argv, "1ACFLRTacdfgiloqrstu")) != EOF) {
+ while ((ch = getopt(argc, argv, "1ACFLRTWacdfgiloqrstu")) != EOF) {
switch (ch) {
/*
* The -1, -C and -l options all override each other so shell
@@ -193,6 +194,9 @@ main(argc, argv)
case 't':
f_timesort = 1;
break;
+ case 'W':
+ f_whiteout = 1;
+ break;
default:
case '?':
usage();
@@ -215,6 +219,14 @@ main(argc, argv)
if (!f_longform && !f_listdir && !f_type)
fts_options |= FTS_COMFOLLOW;
+ /*
+ * If -W, show whiteout entries
+ */
+#ifdef FTS_WHITEOUT
+ if (f_whiteout)
+ fts_options |= FTS_WHITEOUT;
+#endif
+
/* If -l or -s, figure out block size. */
if (f_longform || f_size) {
(void)getbsize(&notused, &blocksize);
diff --git a/bin/ls/print.c b/bin/ls/print.c
index 5c068e9..c5e6484 100644
--- a/bin/ls/print.c
+++ b/bin/ls/print.c
@@ -35,7 +35,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)print.c 8.4 (Berkeley) 4/17/94";
+static char sccsid[] = "@(#)print.c 8.5 (Berkeley) 7/28/94";
#endif /* not lint */
#include <sys/param.h>
@@ -264,6 +264,9 @@ printtype(mode)
case S_IFSOCK:
(void)putchar('=');
return (1);
+ case S_IFWHT:
+ (void)putchar('%');
+ return (1);
}
if (mode & (S_IXUSR | S_IXGRP | S_IXOTH)) {
(void)putchar('*');
diff --git a/bin/ls/stat_flags.c b/bin/ls/stat_flags.c
index 5bc4b85..794bce6 100644
--- a/bin/ls/stat_flags.c
+++ b/bin/ls/stat_flags.c
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)stat_flags.c 8.1 (Berkeley) 5/31/93";
+static char sccsid[] = "@(#)stat_flags.c 8.2 (Berkeley) 7/28/94";
#endif /* not lint */
#include <sys/types.h>
@@ -69,6 +69,8 @@ flags_to_string(flags, def)
SAPPEND("uchg");
if (flags & UF_NODUMP)
SAPPEND("nodump");
+ if (flags & UF_OPAQUE)
+ SAPPEND("opaque");
if (flags & SF_APPEND)
SAPPEND("sappnd");
if (flags & SF_ARCHIVED)
@@ -126,6 +128,9 @@ string_to_flags(stringp, setp, clrp)
clear = !clear;
TEST(p, "dump", UF_NODUMP);
return (1);
+ case 'o':
+ TEST(p, "opaque", UF_OPAQUE);
+ return (1);
case 's':
TEST(p, "sappnd", SF_APPEND);
TEST(p, "sappend", SF_APPEND);
diff --git a/bin/ls/util.c b/bin/ls/util.c
index 4d1173d..b826873 100644
--- a/bin/ls/util.c
+++ b/bin/ls/util.c
@@ -35,7 +35,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)util.c 8.3 (Berkeley) 4/2/94";
+static char sccsid[] = "@(#)util.c 8.5 (Berkeley) 4/28/95";
#endif /* not lint */
#include <sys/types.h>
@@ -66,6 +66,7 @@ prcopy(src, dest, len)
void
usage()
{
- (void)fprintf(stderr, "usage: ls [-1ACFLRTacdfiklqrstu] [file ...]\n");
+ (void)fprintf(stderr,
+ "usage: ls [-1ACFLRTWacdfikloqrstu] [file ...]\n");
exit(1);
}
diff --git a/bin/ps/fmt.c b/bin/ps/fmt.c
index 3b6a1ec..de1812f 100644
--- a/bin/ps/fmt.c
+++ b/bin/ps/fmt.c
@@ -32,17 +32,19 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)fmt.c 8.4 (Berkeley) 4/15/94";
+static char sccsid[] = "@(#)fmt.c 8.5 (Berkeley) 4/27/95";
#endif /* not lint */
#include <sys/param.h>
#include <sys/time.h>
#include <sys/resource.h>
+
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vis.h>
+
#include "ps.h"
static char *cmdpart __P((char *));
@@ -72,6 +74,8 @@ shquote(argv)
dst++;
*dst++ = ' ';
}
+ if (dst != buf)
+ --dst;
*dst = '\0';
return (buf);
}
diff --git a/bin/pwd/pwd.1 b/bin/pwd/pwd.1
index b0d6ee3..84f0913 100644
--- a/bin/pwd/pwd.1
+++ b/bin/pwd/pwd.1
@@ -32,9 +32,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)pwd.1 8.1 (Berkeley) 5/31/93
+.\" @(#)pwd.1 8.2 (Berkeley) 4/28/95
.\"
-.Dd May 31, 1993
+.Dd April 28, 1995
.Dt PWD 1
.Os BSD 4
.Sh NAME
@@ -57,7 +57,7 @@ compatible .
.Sh SEE ALSO
.Xr cd 1 ,
.Xr csh 1 ,
-.Xr getwd 3
+.Xr getcwd 3
.Sh BUGS
In
.Xr csh 1
diff --git a/bin/rm/rm.1 b/bin/rm/rm.1
index 6316d35..8344bde 100644
--- a/bin/rm/rm.1
+++ b/bin/rm/rm.1
@@ -32,9 +32,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)rm.1 8.2 (Berkeley) 4/18/94
+.\" @(#)rm.1 8.5 (Berkeley) 12/5/94
.\"
-.Dd April 18, 1994
+.Dd December 5, 1994
.Dt RM 1
.Os
.Sh NAME
@@ -43,7 +43,7 @@
.Sh SYNOPSIS
.Nm rm
.Op Fl f | Fl i
-.Op Fl dPRr
+.Op Fl dPRrW
.Ar file ...
.Sh DESCRIPTION
The
@@ -99,6 +99,10 @@ that directory is skipped.
.It Fl r
Equivalent to
.Fl R .
+.It Fl W
+Attempts to undelete the named files.
+Currently, this option can only be used to recover
+files covered by whiteouts.
.El
.Pp
The
@@ -119,6 +123,7 @@ If an error occurs,
exits with a value >0.
.Sh SEE ALSO
.Xr rmdir 1 ,
+.Xr undelete 2 ,
.Xr unlink 2 ,
.Xr fts 3 ,
.Xr symlink 7
diff --git a/bin/rm/rm.c b/bin/rm/rm.c
index 4cdf055..bcecfe3 100644
--- a/bin/rm/rm.c
+++ b/bin/rm/rm.c
@@ -38,7 +38,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)rm.c 8.5 (Berkeley) 4/18/94";
+static char sccsid[] = "@(#)rm.c 8.8 (Berkeley) 4/27/95";
#endif /* not lint */
#include <sys/types.h>
@@ -53,7 +53,7 @@ static char sccsid[] = "@(#)rm.c 8.5 (Berkeley) 4/18/94";
#include <string.h>
#include <unistd.h>
-int dflag, eval, fflag, iflag, Pflag, stdin_ok;
+int dflag, eval, fflag, iflag, Pflag, Wflag, stdin_ok;
int check __P((char *, char *, struct stat *));
void checkdot __P((char **));
@@ -77,7 +77,7 @@ main(argc, argv)
int ch, rflag;
Pflag = rflag = 0;
- while ((ch = getopt(argc, argv, "dfiPRr")) != EOF)
+ while ((ch = getopt(argc, argv, "dfiPRrW")) != -1)
switch(ch) {
case 'd':
dflag = 1;
@@ -97,6 +97,9 @@ main(argc, argv)
case 'r': /* Compatibility. */
rflag = 1;
break;
+ case 'W':
+ Wflag = 1;
+ break;
case '?':
default:
usage();
@@ -108,15 +111,16 @@ main(argc, argv)
usage();
checkdot(argv);
- if (!*argv)
- exit (eval);
- stdin_ok = isatty(STDIN_FILENO);
+ if (*argv) {
+ stdin_ok = isatty(STDIN_FILENO);
+
+ if (rflag)
+ rm_tree(argv);
+ else
+ rm_file(argv);
+ }
- if (rflag)
- rm_tree(argv);
- else
- rm_file(argv);
exit (eval);
}
@@ -127,6 +131,7 @@ rm_tree(argv)
FTS *fts;
FTSENT *p;
int needstat;
+ int flags;
/*
* Remove a file hierarchy. If forcing removal (-f), or interactive
@@ -140,9 +145,12 @@ rm_tree(argv)
*/
#define SKIPPED 1
- if (!(fts = fts_open(argv,
- needstat ? FTS_PHYSICAL : FTS_PHYSICAL|FTS_NOSTAT,
- (int (*)())NULL)))
+ flags = FTS_PHYSICAL;
+ if (!needstat)
+ flags |= FTS_NOSTAT;
+ if (Wflag)
+ flags |= FTS_WHITEOUT;
+ if (!(fts = fts_open(argv, flags, (int (*)())NULL)))
err(1, NULL);
while ((p = fts_read(fts)) != NULL) {
switch (p->fts_info) {
@@ -170,7 +178,7 @@ rm_tree(argv)
continue;
case FTS_D:
/* Pre-order: give user chance to skip. */
- if (iflag && !check(p->fts_path, p->fts_accpath,
+ if (!fflag && !check(p->fts_path, p->fts_accpath,
p->fts_statp)) {
(void)fts_set(fts, p, FTS_SKIP);
p->fts_number = SKIPPED;
@@ -181,25 +189,31 @@ rm_tree(argv)
if (p->fts_number == SKIPPED)
continue;
break;
+ default:
+ if (!fflag &&
+ !check(p->fts_path, p->fts_accpath, p->fts_statp))
+ continue;
}
- if (!fflag &&
- !check(p->fts_path, p->fts_accpath, p->fts_statp))
- continue;
/*
* If we can't read or search the directory, may still be
* able to remove it. Don't print out the un{read,search}able
* message unless the remove fails.
*/
- if (p->fts_info == FTS_DP || p->fts_info == FTS_DNR) {
- if (!rmdir(p->fts_accpath))
+ switch (p->fts_info) {
+ case FTS_DP:
+ case FTS_DNR:
+ if (!rmdir(p->fts_accpath) || fflag && errno == ENOENT)
continue;
- if (errno == ENOENT) {
- if (fflag)
- continue;
- } else if (p->fts_info != FTS_DP)
- warnx("%s: unable to read", p->fts_path);
- } else {
+ break;
+
+ case FTS_W:
+ if (!undelete(p->fts_accpath) ||
+ fflag && errno == ENOENT)
+ continue;
+ break;
+
+ default:
if (Pflag)
rm_overwrite(p->fts_accpath, NULL);
if (!unlink(p->fts_accpath) || fflag && errno == ENOENT)
@@ -217,10 +231,9 @@ rm_file(argv)
char **argv;
{
struct stat sb;
- int df, rval;
+ int rval;
char *f;
- df = dflag;
/*
* Remove a file. POSIX 1003.2 states that, by default, attempting
* to remove a directory is an error, so must always stat the file.
@@ -228,20 +241,31 @@ rm_file(argv)
while ((f = *argv++) != NULL) {
/* Assume if can't stat the file, can't unlink it. */
if (lstat(f, &sb)) {
- if (!fflag || errno != ENOENT) {
- warn("%s", f);
- eval = 1;
+ if (Wflag) {
+ sb.st_mode = S_IFWHT|S_IWUSR|S_IRUSR;
+ } else {
+ if (!fflag || errno != ENOENT) {
+ warn("%s", f);
+ eval = 1;
+ }
+ continue;
}
+ } else if (Wflag) {
+ warnx("%s: %s", f, strerror(EEXIST));
+ eval = 1;
continue;
}
- if (S_ISDIR(sb.st_mode) && !df) {
+
+ if (S_ISDIR(sb.st_mode) && !dflag) {
warnx("%s: is a directory", f);
eval = 1;
continue;
}
- if (!fflag && !check(f, f, &sb))
+ if (!fflag && !S_ISWHT(sb.st_mode) && !check(f, f, &sb))
continue;
- if (S_ISDIR(sb.st_mode))
+ if (S_ISWHT(sb.st_mode))
+ rval = undelete(f);
+ else if (S_ISDIR(sb.st_mode))
rval = rmdir(f);
else {
if (Pflag)
@@ -362,7 +386,8 @@ checkdot(argv)
if (!complained++)
warnx("\".\" and \"..\" may not be removed");
eval = 1;
- for (save = t; (t[0] = t[1]) != NULL; ++t);
+ for (save = t; (t[0] = t[1]) != NULL; ++t)
+ continue;
t = save;
} else
++t;
@@ -373,6 +398,6 @@ void
usage()
{
- (void)fprintf(stderr, "usage: rm [-dfiRr] file ...\n");
+ (void)fprintf(stderr, "usage: rm [-dfiPRrW] file ...\n");
exit(1);
}
diff --git a/bin/rmail/rmail.c b/bin/rmail/rmail.c
index aac400a..29af02a 100644
--- a/bin/rmail/rmail.c
+++ b/bin/rmail/rmail.c
@@ -38,7 +38,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "@(#)rmail.c 8.1 (Berkeley) 5/31/93";
+static char sccsid[] = "@(#)rmail.c 8.3 (Berkeley) 5/15/95";
#endif /* not lint */
/*
@@ -78,6 +78,10 @@ static char sccsid[] = "@(#)rmail.c 8.1 (Berkeley) 5/31/93";
#include <sysexits.h>
#include <unistd.h>
+#ifndef MAX
+# define MAX(a, b) ((a) < (b) ? (b) : (a))
+#endif
+
void err __P((int, const char *, ...));
void usage __P((void));
@@ -207,6 +211,8 @@ main(argc, argv)
/* Save off from user's address; the last one wins. */
for (p = addrp; *p && !isspace(*p); ++p);
*p = '\0';
+ if (*addrp == '\0')
+ addrp = "<>";
if (from_user != NULL)
free(from_user);
if ((from_user = strdup(addrp)) == NULL)
@@ -229,17 +235,14 @@ main(argc, argv)
args[i++] = "-odq"; /* Queue it, don't try to deliver. */
args[i++] = "-oi"; /* Ignore '.' on a line by itself. */
- if (from_sys != NULL) { /* Set sender's host name. */
- if (strchr(from_sys, '.') == NULL)
- (void)snprintf(buf, sizeof(buf),
- "-oMs%s.%s", from_sys, domain);
- else
- (void)snprintf(buf, sizeof(buf), "-oMs%s", from_sys);
- if ((args[i++] = strdup(buf)) == NULL)
- err(EX_TEMPFAIL, NULL);
- }
- /* Set protocol used. */
- (void)snprintf(buf, sizeof(buf), "-oMr%s", domain);
+ /* set from system and protocol used */
+ if (from_sys == NULL)
+ (void)snprintf(buf, sizeof(buf), "-p%s", domain);
+ else if (strchr(from_sys, '.') == NULL)
+ (void)snprintf(buf, sizeof(buf), "-p%s:%s.%s",
+ domain, from_sys, domain);
+ else
+ (void)snprintf(buf, sizeof(buf), "-p%s:%s", domain, from_sys);
if ((args[i++] = strdup(buf)) == NULL)
err(EX_TEMPFAIL, NULL);
@@ -252,11 +255,22 @@ main(argc, argv)
/*
* Don't copy arguments beginning with - as they will be
* passed to sendmail and could be interpreted as flags.
+ * To prevent confusion of sendmail wrap < and > around
+ * the address (helps to pass addrs like @gw1,@gw2:aa@bb)
*/
- do {
- if (*argv && **argv == '-')
+ while (*argv) {
+ if (**argv == '-')
err(EX_USAGE, "dash precedes argument: %s", *argv);
- } while ((args[i++] = *argv++) != NULL);
+ if (strchr(*argv, ',') == NULL || strchr(*argv, '<') != NULL)
+ args[i++] = *argv;
+ else {
+ if ((args[i] = malloc(strlen(*argv) + 3)) == NULL)
+ err(EX_TEMPFAIL, "Cannot malloc");
+ sprintf (args [i++], "<%s>", *argv);
+ }
+ argv++;
+ }
+ args[i] = 0;
if (debug) {
(void)fprintf(stderr, "Sendmail arguments:\n");
diff --git a/bin/stty/key.c b/bin/stty/key.c
index cf4fde4..713ff58 100644
--- a/bin/stty/key.c
+++ b/bin/stty/key.c
@@ -32,7 +32,7 @@
*/
#ifndef lint
-static char sccsid[] = "@(#)key.c 8.3 (Berkeley) 4/2/94";
+static char sccsid[] = "@(#)key.c 8.4 (Berkeley) 2/20/95";
#endif /* not lint */
#include <sys/types.h>
@@ -190,13 +190,14 @@ f_extproc(ip)
struct info *ip;
{
- if (ip->set) {
- int tmp = 1;
+ if (ip->off) {
+ int tmp = 0;
(void)ioctl(ip->fd, TIOCEXT, &tmp);
} else {
- int tmp = 0;
+ int tmp = 1;
(void)ioctl(ip->fd, TIOCEXT, &tmp);
}
+ ip->set = 1;
}
void
diff --git a/bin/stty/stty.1 b/bin/stty/stty.1
index e9665d7..ac2ab16 100644
--- a/bin/stty/stty.1
+++ b/bin/stty/stty.1
@@ -32,9 +32,9 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" @(#)stty.1 8.4 (Berkeley) 4/18/94
+.\" @(#)stty.1 8.5 (Berkeley) 6/1/94
.\"
-.Dd April 18, 1994
+.Dd June 1, 1994
.Dt STTY 1
.Os
.Sh NAME
@@ -124,6 +124,7 @@ If
the output baud rate is set to
zero, modem control is
no longer asserted.
+.ne 1i
.It Cm speed Ar number
This sets both
.Cm ispeed
@@ -199,6 +200,7 @@ receives
or if
.Cm ixany
is set, any character restarts output.
+.ne 1i
.It Cm ixoff Pq Fl ixoff
Request that the system send (not
send)
@@ -294,6 +296,7 @@ Echo (do not echo)
after
.Dv KILL
character.
+.ne 1i
.It Cm echoke Pq Fl echoke
The
.Dv KILL
@@ -445,6 +448,7 @@ columns.
.It Cm cols Ar number
is an alias for
.Cm columns.
+.ne 1i
.It Cm rows Ar number
The terminal size is recorded as having
.Ar number
@@ -530,6 +534,7 @@ Same as
.It Cm decctlq Pq Fl decctlq
The converse of
.Cm ixany .
+.ne 1i
.It Cm crterase Pq Fl crterase
Same as
.Cm echoe .
OpenPOWER on IntegriCloud