CVS commit: src/bin/csh
Module Name:src Committed By: christos Date: Sun Aug 15 12:16:02 UTC 2021 Modified Files: src/bin/csh: set.c Log Message: Turn on EL_SAFEREAD To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/bin/csh/set.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/csh/set.c diff -u src/bin/csh/set.c:1.37 src/bin/csh/set.c:1.38 --- src/bin/csh/set.c:1.37 Sun Jan 12 13:42:41 2020 +++ src/bin/csh/set.c Sun Aug 15 08:16:02 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: set.c,v 1.37 2020/01/12 18:42:41 christos Exp $ */ +/* $NetBSD: set.c,v 1.38 2021/08/15 12:16:02 christos Exp $ */ /*- * Copyright (c) 1980, 1991, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)set.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: set.c,v 1.37 2020/01/12 18:42:41 christos Exp $"); +__RCSID("$NetBSD: set.c,v 1.38 2021/08/15 12:16:02 christos Exp $"); #endif #endif /* not lint */ @@ -158,6 +158,7 @@ update_vars(Char *vp) el_set(el, EL_EDITOR, *vn ? short2str(vn) : "emacs"); el_set(el, EL_PROMPT, printpromptstr); el_set(el, EL_ALIAS_TEXT, alias_text, NULL); + el_set(el, EL_SAFEREAD, 1); el_set(el, EL_ADDFN, "rl-complete", "ReadLine compatible completion function", _el_fn_complete); el_set(el, EL_BIND, "^I", adrof(STRfilec) ? "rl-complete" : "ed-insert",
CVS commit: src/bin/sh
Module Name:src Committed By: christos Date: Sun Aug 15 11:57:17 UTC 2021 Modified Files: src/bin/sh: Makefile Log Message: Add -I to find filecomplete.h To generate a diff of this commit: cvs rdiff -u -r1.116 -r1.117 src/bin/sh/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/Makefile diff -u src/bin/sh/Makefile:1.116 src/bin/sh/Makefile:1.117 --- src/bin/sh/Makefile:1.116 Wed May 26 16:21:52 2021 +++ src/bin/sh/Makefile Sun Aug 15 07:57:17 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.116 2021/05/26 20:21:52 christos Exp $ +# $NetBSD: Makefile,v 1.117 2021/08/15 11:57:17 christos Exp $ # @(#)Makefile 8.4 (Berkeley) 5/5/95 .include @@ -23,7 +23,7 @@ SCRIPT_ENV= \ MKTEMP=${TOOL_MKTEMP:Q} \ SED=${TOOL_SED:Q} -CPPFLAGS+=-DSHELL -I. -I${.CURDIR} +CPPFLAGS+=-DSHELL -I. -I${.CURDIR} -I${NETBSDSRCDIR}/lib/libedit CPPFLAGS+= -DUSE_LRAND48 #XXX: For testing only. #CPPFLAGS+=-DDEBUG=1
CVS commit: src/bin/kill
Module Name:src Committed By: christos Date: Sun Aug 15 10:58:04 UTC 2021 Modified Files: src/bin/kill: kill.1 Log Message: restore a bit of history. To generate a diff of this commit: cvs rdiff -u -r1.33 -r1.34 src/bin/kill/kill.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/kill/kill.1 diff -u src/bin/kill/kill.1:1.33 src/bin/kill/kill.1:1.34 --- src/bin/kill/kill.1:1.33 Sun Aug 30 16:14:07 2020 +++ src/bin/kill/kill.1 Sun Aug 15 06:58:04 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: kill.1,v 1.33 2020/08/30 20:14:07 wiz Exp $ +.\" $NetBSD: kill.1,v 1.34 2021/08/15 10:58:04 christos Exp $ .\" .\" Copyright (c) 1980, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -32,7 +32,7 @@ .\" .\" @(#)kill.1 8.2 (Berkeley) 4/28/95 .\" -.Dd August 30, 2020 +.Dd August 15, 2021 .Dt KILL 1 .Os .Sh NAME @@ -192,3 +192,5 @@ A command appeared in .At v3 in section 8 of the manual. +The original BSD description was: +.Sq terminate a process with extreme prejudice .
CVS commit: src/bin/sh
Module Name:src Committed By: christos Date: Sun Aug 15 10:17:55 UTC 2021 Modified Files: src/bin/sh: histedit.c myhistedit.h Log Message: - Add command completion (from FreeBSD) - Use EL_SAFEREAD To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 src/bin/sh/histedit.c cvs rdiff -u -r1.13 -r1.14 src/bin/sh/myhistedit.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/histedit.c diff -u src/bin/sh/histedit.c:1.55 src/bin/sh/histedit.c:1.56 --- src/bin/sh/histedit.c:1.55 Sun Feb 10 14:21:52 2019 +++ src/bin/sh/histedit.c Sun Aug 15 06:17:55 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: histedit.c,v 1.55 2019/02/10 19:21:52 kre Exp $ */ +/* $NetBSD: histedit.c,v 1.56 2021/08/15 10:17:55 christos Exp $ */ /*- * Copyright (c) 1993 @@ -37,11 +37,13 @@ #if 0 static char sccsid[] = "@(#)histedit.c 8.2 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: histedit.c,v 1.55 2019/02/10 19:21:52 kre Exp $"); +__RCSID("$NetBSD: histedit.c,v 1.56 2021/08/15 10:17:55 christos Exp $"); #endif #endif /* not lint */ #include +#include +#include #include #include #include @@ -71,13 +73,19 @@ History *hist; /* history cookie */ EditLine *el; /* editline cookie */ int displayhist; static FILE *el_in, *el_out; - -STATIC const char *fc_replace(const char *, char *, char *); +static int curpos; #ifdef DEBUG extern FILE *tracefile; #endif +static const char *fc_replace(const char *, char *, char *); +static int not_fcnumber(const char *); +static int str_to_event(const char *, int); +static int comparator(const void *, const void *); +static char **sh_matches(const char *, int, int); +static unsigned char sh_complete(EditLine *, int); + /* * Set history and editing status. Called whenever the status may * have changed (figures out what to do). @@ -136,10 +144,11 @@ histedit(void) set_prompt_lit(lookupvar("PSlit")); el_set(el, EL_SIGNAL, 1); +el_set(el, EL_SAFEREAD, 1); el_set(el, EL_ALIAS_TEXT, alias_text, NULL); el_set(el, EL_ADDFN, "rl-complete", "ReadLine compatible completion function", -_el_fn_complete); +sh_complete); } else { bad: out2str("sh: can't initialize editing\n"); @@ -493,7 +502,7 @@ histcmd(volatile int argc, char ** volat return 0; } -STATIC const char * +static const char * fc_replace(const char *s, char *p, char *r) { char *dest; @@ -512,20 +521,123 @@ fc_replace(const char *s, char *p, char STACKSTRNUL(dest); dest = grabstackstr(dest); - return (dest); + return dest; } -int -not_fcnumber(char *s) + +/* + * Comparator function for qsort(). The use of curpos here is to skip + * characters that we already know to compare equal (common prefix). + */ +static int +comparator(const void *a, const void *b) +{ + return strcmp(*(char *const *)a + curpos, + *(char *const *)b + curpos); +} + +/* + * This function is passed to libedit's fn_complete(). The library will + * use it instead of its standard function to find matches, which + * searches for files in current directory. If we're at the start of the + * line, we want to look for available commands from all paths in $PATH. + */ +static char +**sh_matches(const char *text, int start, int end) +{ + char *free_path = NULL, *dirname, *path; + char **matches = NULL; + size_t i = 0, size = 16; + + if (start > 0) + return NULL; + curpos = end - start; + if ((free_path = path = strdup(pathval())) == NULL) + goto out; + if ((matches = malloc(size * sizeof(matches[0]))) == NULL) + goto out; + while ((dirname = strsep(, ":")) != NULL) { + struct dirent *entry; + DIR *dir; + int dfd; + + if ((dir = opendir(dirname)) == NULL) + continue; + if ((dfd = dirfd(dir)) == -1) + continue; + while ((entry = readdir(dir)) != NULL) { + struct stat statb; + + if (strncmp(entry->d_name, text, curpos) != 0) +continue; + if (entry->d_type == DT_UNKNOWN || entry->d_type == DT_LNK) { +if (fstatat(dfd, entry->d_name, , 0) == -1) + continue; +if (!S_ISREG(statb.st_mode)) + continue; + } else if (entry->d_type != DT_REG) +continue; + if (++i >= size - 1) { +size *= 2; +if (reallocarr(, size, +sizeof(*matches))) +{ + closedir(dir); + goto out; +} + } + matches[i] = strdup(entry->d_name); + } + closedir(dir); + } +out: + free(free_path); + if (i == 0) { + free(matches); + return NULL; + } + if (i == 1) { + matches[0] = strdup(matches[1]); + matches[i + 1] = NULL; + } else { + size_t j, k; + + qsort(matches + 1, i, sizeof(matches[0]), comparator); + for (j = 1, k = 2; k <= i; k++) + if (strcmp(matches[j] + curpos, matches[k] + curpos) + == 0) +free(matches[k]); + else +matches[++j] = matches[k]; + matches[0] = strdup(text); + matches[j + 1] = NULL; + } + return matches; +} + +/* + * This is passed to el_set(el, EL_ADDFN, ...) so that it's possible to + * bind
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Mon Aug 9 11:29:30 UTC 2021 Modified Files: src/bin/sh: var.c Log Message: Fix the fix to a typo in one of the comments. To generate a diff of this commit: cvs rdiff -u -r1.79 -r1.80 src/bin/sh/var.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/var.c diff -u src/bin/sh/var.c:1.79 src/bin/sh/var.c:1.80 --- src/bin/sh/var.c:1.79 Sun Aug 8 20:50:12 2021 +++ src/bin/sh/var.c Mon Aug 9 11:29:30 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.79 2021/08/08 20:50:12 andvar Exp $ */ +/* $NetBSD: var.c,v 1.80 2021/08/09 11:29:30 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: var.c,v 1.79 2021/08/08 20:50:12 andvar Exp $"); +__RCSID("$NetBSD: var.c,v 1.80 2021/08/09 11:29:30 kre Exp $"); #endif #endif /* not lint */ @@ -1248,7 +1248,7 @@ unsetvar(const char *s, int unexport) /* - * Returns true if the two strings specify the same viarable. The first + * Returns true if the two strings specify the same variable. The first * variable name is terminated by '='; the second may be terminated by * either '=' or '\0'. */
CVS commit: src/bin/ps
Module Name:src Committed By: christos Date: Fri Jun 4 22:39:41 UTC 2021 Modified Files: src/bin/ps: ps.c Log Message: use parsenum like everywhere else in the code. To generate a diff of this commit: cvs rdiff -u -r1.95 -r1.96 src/bin/ps/ps.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/ps.c diff -u src/bin/ps/ps.c:1.95 src/bin/ps/ps.c:1.96 --- src/bin/ps/ps.c:1.95 Fri Jun 4 04:17:53 2021 +++ src/bin/ps/ps.c Fri Jun 4 18:39:41 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ps.c,v 1.95 2021/06/04 08:17:53 wiz Exp $ */ +/* $NetBSD: ps.c,v 1.96 2021/06/04 22:39:41 christos Exp $ */ /* * Copyright (c) 2000-2008 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 19 #if 0 static char sccsid[] = "@(#)ps.c 8.4 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: ps.c,v 1.95 2021/06/04 08:17:53 wiz Exp $"); +__RCSID("$NetBSD: ps.c,v 1.96 2021/06/04 22:39:41 christos Exp $"); #endif #endif /* not lint */ @@ -257,20 +257,13 @@ main(int argc, char *argv[]) case 'G': if (*optarg != '\0') { struct group *gr; -char *ep; what = KERN_PROC_GID; gr = getgrnam(optarg); if (gr == NULL) { - errno = 0; - flag = strtoul(optarg, , 10); - if (errno) - err(1, "%s", optarg); - if (*ep != '\0') - errx(1, "%s: illegal group", - optarg); - } else - flag = gr->gr_gid; + flag = parsenum(optarg, "group id"); +} else + flag = gr->gr_gid; } break; @@ -359,7 +352,7 @@ main(int argc, char *argv[]) what = KERN_PROC_UID; pw = getpwnam(optarg); if (pw == NULL) { - flag = parsenum(optarg, "user name"); + flag = parsenum(optarg, "user id"); } else flag = pw->pw_uid; }
CVS commit: src/bin/ps
Module Name:src Committed By: wiz Date: Fri Jun 4 08:17:53 UTC 2021 Modified Files: src/bin/ps: ps.c Log Message: Sort options in usage. To generate a diff of this commit: cvs rdiff -u -r1.94 -r1.95 src/bin/ps/ps.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/ps.c diff -u src/bin/ps/ps.c:1.94 src/bin/ps/ps.c:1.95 --- src/bin/ps/ps.c:1.94 Fri Jun 4 06:28:42 2021 +++ src/bin/ps/ps.c Fri Jun 4 08:17:53 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ps.c,v 1.94 2021/06/04 06:28:42 cjep Exp $ */ +/* $NetBSD: ps.c,v 1.95 2021/06/04 08:17:53 wiz Exp $ */ /* * Copyright (c) 2000-2008 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 19 #if 0 static char sccsid[] = "@(#)ps.c 8.4 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: ps.c,v 1.94 2021/06/04 06:28:42 cjep Exp $"); +__RCSID("$NetBSD: ps.c,v 1.95 2021/06/04 08:17:53 wiz Exp $"); #endif #endif /* not lint */ @@ -965,8 +965,8 @@ usage(void) (void)fprintf(stderr, "usage:\t%s\n\t %s\n\t%s\n", - "ps [-AaCcdehjlmrSsTuvwx] [-k key] [-M core] [-N system] [-O fmt]", - "[-o fmt] [-p pid] [-t tty] [-U user] [-G group] [-W swap]", + "ps [-AaCcdehjlmrSsTuvwx] [-G group] [-k key] [-M core] [-N system]", + "[-O fmt] [-o fmt] [-p pid] [-t tty] [-U user] [-W swap]", "ps -L"); exit(1); /* NOTREACHED */
CVS commit: src/bin/ps
Module Name:src Committed By: wiz Date: Fri Jun 4 08:16:14 UTC 2021 Modified Files: src/bin/ps: ps.1 Log Message: Sort options in synopsis. To generate a diff of this commit: cvs rdiff -u -r1.111 -r1.112 src/bin/ps/ps.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/ps.1 diff -u src/bin/ps/ps.1:1.111 src/bin/ps/ps.1:1.112 --- src/bin/ps/ps.1:1.111 Fri Jun 4 06:28:42 2021 +++ src/bin/ps/ps.1 Fri Jun 4 08:16:14 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: ps.1,v 1.111 2021/06/04 06:28:42 cjep Exp $ +.\" $NetBSD: ps.1,v 1.112 2021/06/04 08:16:14 wiz Exp $ .\" .\" Copyright (c) 1980, 1990, 1991, 1993, 1994 .\" The Regents of the University of California. All rights reserved. @@ -38,6 +38,7 @@ .Sh SYNOPSIS .Nm .Op Fl AaCcdehjlmrSsTuvwx +.Op Fl G Ar group .Op Fl k Ar key .Op Fl M Ar core .Op Fl N Ar system @@ -46,7 +47,6 @@ .Op Fl p Ar pid .Op Fl t Ar tty .Op Fl U Ar user -.Op Fl G Ar group .Op Fl W Ar swap .Nm .Fl L @@ -719,6 +719,6 @@ Since cannot run faster than the system and is run as any other scheduled process, the information it displays can never be exact. .Pp -The -.Fl G +The +.Fl G option should ideally take a list instead of a single group.
CVS commit: src/bin/ps
Module Name:src Committed By: cjep Date: Fri Jun 4 06:28:42 UTC 2021 Modified Files: src/bin/ps: ps.1 ps.c Log Message: PR standards/11223 Add -G to take a single group argument heading towards POSIX.2 compliance. Patch from jperkin and reviewed by simonb. To generate a diff of this commit: cvs rdiff -u -r1.110 -r1.111 src/bin/ps/ps.1 cvs rdiff -u -r1.93 -r1.94 src/bin/ps/ps.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/ps.1 diff -u src/bin/ps/ps.1:1.110 src/bin/ps/ps.1:1.111 --- src/bin/ps/ps.1:1.110 Tue Aug 6 18:07:51 2019 +++ src/bin/ps/ps.1 Fri Jun 4 06:28:42 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: ps.1,v 1.110 2019/08/06 18:07:51 kamil Exp $ +.\" $NetBSD: ps.1,v 1.111 2021/06/04 06:28:42 cjep Exp $ .\" .\" Copyright (c) 1980, 1990, 1991, 1993, 1994 .\" The Regents of the University of California. All rights reserved. @@ -46,6 +46,7 @@ .Op Fl p Ar pid .Op Fl t Ar tty .Op Fl U Ar user +.Op Fl G Ar group .Op Fl W Ar swap .Nm .Fl L @@ -110,6 +111,9 @@ relative to each other. Display the environment as well. The environment for other users' processes can only be displayed by the super-user. +.It Fl G Ar group +Display processes belonging to the users belonging to the specified group, +given either as a group name or a gid. .It Fl h Repeat the information header as often as necessary to guarantee one header per page of information. @@ -714,3 +718,7 @@ Since .Nm cannot run faster than the system and is run as any other scheduled process, the information it displays can never be exact. +.Pp +The +.Fl G +option should ideally take a list instead of a single group. Index: src/bin/ps/ps.c diff -u src/bin/ps/ps.c:1.93 src/bin/ps/ps.c:1.94 --- src/bin/ps/ps.c:1.93 Sun Sep 15 15:27:50 2019 +++ src/bin/ps/ps.c Fri Jun 4 06:28:42 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: ps.c,v 1.93 2019/09/15 15:27:50 kamil Exp $ */ +/* $NetBSD: ps.c,v 1.94 2021/06/04 06:28:42 cjep Exp $ */ /* * Copyright (c) 2000-2008 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ __COPYRIGHT("@(#) Copyright (c) 1990, 19 #if 0 static char sccsid[] = "@(#)ps.c 8.4 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: ps.c,v 1.93 2019/09/15 15:27:50 kamil Exp $"); +__RCSID("$NetBSD: ps.c,v 1.94 2021/06/04 06:28:42 cjep Exp $"); #endif #endif /* not lint */ @@ -86,6 +86,7 @@ __RCSID("$NetBSD: ps.c,v 1.93 2019/09/15 #include #include #include +#include #include #include #include @@ -104,8 +105,8 @@ __RCSID("$NetBSD: ps.c,v 1.93 2019/09/15 * ARGOPTS must contain all option characters that take arguments * (except for 't'!) - it is used in kludge_oldps_options() */ -#define GETOPTSTR "aAcCdeghjk:LlM:mN:O:o:p:rSsTt:U:uvW:wx" -#define ARGOPTS "kMNOopUW" +#define GETOPTSTR "aAcCdegG:hjk:LlM:mN:O:o:p:rSsTt:U:uvW:wx" +#define ARGOPTS "GkMNOopUW" struct varlist displaylist = SIMPLEQ_HEAD_INITIALIZER(displaylist); struct varlist sortlist = SIMPLEQ_HEAD_INITIALIZER(sortlist); @@ -253,6 +254,26 @@ main(int argc, char *argv[]) break; case 'g': break; /* no-op */ + case 'G': + if (*optarg != '\0') { +struct group *gr; +char *ep; + +what = KERN_PROC_GID; +gr = getgrnam(optarg); +if (gr == NULL) { + errno = 0; + flag = strtoul(optarg, , 10); + if (errno) + err(1, "%s", optarg); + if (*ep != '\0') + errx(1, "%s: illegal group", + optarg); + } else + flag = gr->gr_gid; + } + break; + case 'h': prtheader = ws.ws_row > 5 ? ws.ws_row : 22; break; @@ -945,7 +966,7 @@ usage(void) (void)fprintf(stderr, "usage:\t%s\n\t %s\n\t%s\n", "ps [-AaCcdehjlmrSsTuvwx] [-k key] [-M core] [-N system] [-O fmt]", - "[-o fmt] [-p pid] [-t tty] [-U user] [-W swap]", + "[-o fmt] [-p pid] [-t tty] [-U user] [-G group] [-W swap]", "ps -L"); exit(1); /* NOTREACHED */
CVS commit: src/bin/sh
Module Name:src Committed By: christos Date: Wed May 26 20:21:52 UTC 2021 Modified Files: src/bin/sh: Makefile Log Message: Use the date tool To generate a diff of this commit: cvs rdiff -u -r1.115 -r1.116 src/bin/sh/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/Makefile diff -u src/bin/sh/Makefile:1.115 src/bin/sh/Makefile:1.116 --- src/bin/sh/Makefile:1.115 Sun Oct 28 14:13:47 2018 +++ src/bin/sh/Makefile Wed May 26 16:21:52 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.115 2018/10/28 18:13:47 kre Exp $ +# $NetBSD: Makefile,v 1.116 2021/05/26 20:21:52 christos Exp $ # @(#)Makefile 8.4 (Berkeley) 5/5/95 .include @@ -33,7 +33,7 @@ CPPFLAGS+= -DUSE_LRAND48 # Reproducible build parameters ... export into sh for NETBSD_SHELL setting .if ${MKREPRO_TIMESTAMP:Uno} != "no" -BUILD_DATE!= date -u -r "${MKREPRO_TIMESTAMP}" "+%Y%m%d%H%M%S" +BUILD_DATE!= ${TOOL_DATE} -u -r "${MKREPRO_TIMESTAMP}" "+%Y%m%d%H%M%S" # These are (should be) equivalent, but the 2nd is easier to understand #CPPFLAGS+= -DBUILD_DATE='"${BUILD_DATE:C/([^0]0?)(00)*$/\1/}Z"' CPPFLAGS+= -DBUILD_DATE='"${BUILD_DATE:S/00$//:S/00$//:S/00$//}Z"'
CVS commit: src/bin/date
Module Name:src Committed By: christos Date: Wed May 26 20:19:51 UTC 2021 Modified Files: src/bin/date: Makefile date.c Log Message: tool changes To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/bin/date/Makefile cvs rdiff -u -r1.61 -r1.62 src/bin/date/date.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/date/Makefile diff -u src/bin/date/Makefile:1.15 src/bin/date/Makefile:1.16 --- src/bin/date/Makefile:1.15 Sun Aug 14 06:53:16 2011 +++ src/bin/date/Makefile Wed May 26 16:19:51 2021 @@ -1,10 +1,15 @@ -# $NetBSD: Makefile,v 1.15 2011/08/14 10:53:16 christos Exp $ +# $NetBSD: Makefile,v 1.16 2021/05/26 20:19:51 christos Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 +.include + PROG= date -SRCS= date.c netdate.c +SRCS= date.c +.if !defined(HOSTPROG) +SRCS+= netdate.c DPADD+= ${LIBUTIL} LDADD+= -lutil +.endif CPPFLAGS+=-I${.CURDIR} COPTS.date.c = -Wno-format-nonliteral Index: src/bin/date/date.c diff -u src/bin/date/date.c:1.61 src/bin/date/date.c:1.62 --- src/bin/date/date.c:1.61 Mon Sep 1 17:42:21 2014 +++ src/bin/date/date.c Wed May 26 16:19:51 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: date.c,v 1.61 2014/09/01 21:42:21 dholland Exp $ */ +/* $NetBSD: date.c,v 1.62 2021/05/26 20:19:51 christos Exp $ */ /* * Copyright (c) 1985, 1987, 1988, 1993 @@ -29,6 +29,10 @@ * SUCH DAMAGE. */ +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif + #include #ifndef lint __COPYRIGHT( @@ -40,7 +44,7 @@ __COPYRIGHT( #if 0 static char sccsid[] = "@(#)date.c 8.2 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: date.c,v 1.61 2014/09/01 21:42:21 dholland Exp $"); +__RCSID("$NetBSD: date.c,v 1.62 2021/05/26 20:19:51 christos Exp $"); #endif #endif /* not lint */ @@ -90,6 +94,7 @@ main(int argc, char *argv[]) nflag = 1; break; case 'd': +#ifndef HAVE_NBTOOL_CONFIG_H rflag = 1; tval = parsedate(optarg, NULL, NULL); if (tval == -1) { @@ -97,6 +102,10 @@ main(int argc, char *argv[]) "%s: Unrecognized date format", optarg); } break; +#else + errx(EXIT_FAILURE, + "-d not supported in the tool version"); +#endif case 'j': /* don't set time */ jflag = 1; break; @@ -330,6 +339,7 @@ setthetime(const char *p) } /* set the time */ +#ifndef HAVE_NBTOOL_CONFIG_H if (nflag || netsettime(new_time)) { logwtmp("|", "date", ""); if (aflag) { @@ -346,6 +356,9 @@ setthetime(const char *p) } logwtmp("{", "date", ""); } +#else + errx(EXIT_FAILURE, "Can't set the time in the tools version"); +#endif if ((p = getlogin()) == NULL) p = "???";
CVS commit: src/bin/echo
Module Name:src Committed By: kre Date: Wed May 19 22:12:36 UTC 2021 Modified Files: src/bin/echo: echo.c Log Message: Catch up with /bin/sh built-in echo ... if a write error occurs, don't just exit(1), write an error message to stderr as well (required for POSIX conformance). To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/bin/echo/echo.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/echo/echo.c diff -u src/bin/echo/echo.c:1.19 src/bin/echo/echo.c:1.20 --- src/bin/echo/echo.c:1.19 Mon Sep 5 01:00:07 2016 +++ src/bin/echo/echo.c Wed May 19 22:12:36 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: echo.c,v 1.19 2016/09/05 01:00:07 sevan Exp $ */ +/* $NetBSD: echo.c,v 1.20 2021/05/19 22:12:36 kre Exp $ */ /* * Copyright (c) 1989, 1993 @@ -40,10 +40,11 @@ __COPYRIGHT( #if 0 static char sccsid[] = "@(#)echo.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: echo.c,v 1.19 2016/09/05 01:00:07 sevan Exp $"); +__RCSID("$NetBSD: echo.c,v 1.20 2021/05/19 22:12:36 kre Exp $"); #endif #endif /* not lint */ +#include #include #include #include @@ -75,7 +76,7 @@ main(int argc, char *argv[]) (void)putchar('\n'); fflush(stdout); if (ferror(stdout)) - exit(1); + err(1, "write error"); exit(0); /* NOTREACHED */ }
CVS commit: src/bin/sh/bltin
Module Name:src Committed By: kre Date: Tue May 18 21:39:06 UTC 2021 Modified Files: src/bin/sh/bltin: bltin.h echo.c Log Message: Fix a bug in the built-in echo in /bin/sh reported in private mail by Oguz If echo detects an I/O error, it does exit(1) (that's fine) but then the next echo also does exit(1) even without any errors of its own, and every following echo writing to stdout does the same thing. eg: echo foo >&- ; echo $?; echo $?; ( echo $( echo $?; echo $?) ; echo $? ) 1 1 1 1 1 The first echo writes nothing (stdout is closed) but does exit(1). The second echo writes "1" (correct, the exit status of the previous echo) and should exit(0) - but doesn't. This pattern continues... While here, conform to the POSIX requirement on echo (and many other standard utilities, but definitely not all) that when the utility does exit(>0) a message must be written to stderr (and vice versa in many cases). Our echo (as shown above) did the exit(1) part when it detected the I/O error, but no message is sent to stderr. Fix that while we're here. Similar changes are required for /bin/echo (coming soon), and /usr/bin/printf (which is also the sh builtin printf) - except currently that one kind of conforms, as it ignores errors writing to stdout (as do large numbers of other utilities). For many programs that's kind of acceptable, but where the sole purpose of the program is to write to stdout, it really isn't. Also to be fixed soon. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/bin/sh/bltin/bltin.h cvs rdiff -u -r1.14 -r1.15 src/bin/sh/bltin/echo.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/bltin/bltin.h diff -u src/bin/sh/bltin/bltin.h:1.15 src/bin/sh/bltin/bltin.h:1.16 --- src/bin/sh/bltin/bltin.h:1.15 Mon Jun 26 22:09:16 2017 +++ src/bin/sh/bltin/bltin.h Tue May 18 21:39:06 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: bltin.h,v 1.15 2017/06/26 22:09:16 kre Exp $ */ +/* $NetBSD: bltin.h,v 1.16 2021/05/18 21:39:06 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -58,6 +58,7 @@ #undef putchar #undef fileno #undef ferror +#undef clearerr #define FILE struct output #define stdout out1 #define stderr out2 @@ -74,6 +75,7 @@ #define fflush(f) _RETURN_INT(flushout(f)) #define fileno(f) ((f)->fd) #define ferror(f) ((f)->flags & OUTPUT_ERR) +#define clearerr(f) ((f)->flags &= ~OUTPUT_ERR) #define INITARGS(argv) #define err sh_err #define verr sh_verr Index: src/bin/sh/bltin/echo.c diff -u src/bin/sh/bltin/echo.c:1.14 src/bin/sh/bltin/echo.c:1.15 --- src/bin/sh/bltin/echo.c:1.14 Sun Oct 12 01:40:37 2008 +++ src/bin/sh/bltin/echo.c Tue May 18 21:39:06 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: echo.c,v 1.14 2008/10/12 01:40:37 dholland Exp $ */ +/* $NetBSD: echo.c,v 1.15 2021/05/18 21:39:06 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -52,7 +52,7 @@ */ #include -__RCSID("$NetBSD: echo.c,v 1.14 2008/10/12 01:40:37 dholland Exp $"); +__RCSID("$NetBSD: echo.c,v 1.15 2021/05/18 21:39:06 kre Exp $"); #define main echocmd @@ -68,6 +68,8 @@ main(int argc, char **argv) int nflag = 0; int eflag = 0; + clearerr(stdout); + ap = argv; if (argc) ap++; @@ -116,7 +118,9 @@ main(int argc, char **argv) if (! nflag) putchar('\n'); fflush(stdout); - if (ferror(stdout)) - return 1; + if (ferror(stdout)) { + clearerr(stdout); + err(1, "write error"); + } return 0; }
CVS commit: src/bin/dd
Module Name:src Committed By: nia Date: Tue May 18 07:17:09 UTC 2021 Modified Files: src/bin/dd: dd.1 Log Message: dd.1: add an example of writing a NetBSD image To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/bin/dd/dd.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/dd/dd.1 diff -u src/bin/dd/dd.1:1.36 src/bin/dd/dd.1:1.37 --- src/bin/dd/dd.1:1.36 Wed Jan 30 10:28:50 2019 +++ src/bin/dd/dd.1 Tue May 18 07:17:09 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: dd.1,v 1.36 2019/01/30 10:28:50 wiz Exp $ +.\" $NetBSD: dd.1,v 1.37 2021/05/18 07:17:09 nia Exp $ .\" .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -32,7 +32,7 @@ .\" .\" @(#)dd.1 8.2 (Berkeley) 1/13/94 .\" -.Dd January 29, 2019 +.Dd May 18, 2021 .Dt DD 1 .Os .Sh NAME @@ -546,6 +546,18 @@ for more details. .Sh EXIT STATUS .Ex -std dd .Sh EXAMPLES +To write a +.Xr gzip 1 +compressed +.Nx +image to a removable drive, with +.Xr progress 1 +output: +.Bd -literal -unfilled -offset indent +zcat NetBSD-9.2-amd64-install.img.gz | \\ +progress dd of=/dev/rsd0 bs=1m +.Ed +.Pp To print summary information in human-readable form: .Pp .Dl dd if=/dev/zero of=/dev/null count=1 msgfmt=human
CVS commit: src/bin/ps
Module Name:src Committed By: maya Date: Sat Apr 17 08:35:33 UTC 2021 Modified Files: src/bin/ps: print.c Log Message: Remove SCCS workaround. No binary change. To generate a diff of this commit: cvs rdiff -u -r1.134 -r1.135 src/bin/ps/print.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/print.c diff -u src/bin/ps/print.c:1.134 src/bin/ps/print.c:1.135 --- src/bin/ps/print.c:1.134 Tue Apr 6 13:35:52 2021 +++ src/bin/ps/print.c Sat Apr 17 08:35:33 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: print.c,v 1.134 2021/04/06 13:35:52 christos Exp $ */ +/* $NetBSD: print.c,v 1.135 2021/04/17 08:35:33 maya Exp $ */ /* * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ #if 0 static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; #else -__RCSID("$NetBSD: print.c,v 1.134 2021/04/06 13:35:52 christos Exp $"); +__RCSID("$NetBSD: print.c,v 1.135 2021/04/17 08:35:33 maya Exp $"); #endif #endif /* not lint */ @@ -800,11 +800,9 @@ started(struct pinfo *pi, VARENT *ve, en if (now == 0) (void)time(); if (now - k->p_ustart_sec < SECSPERDAY) - /* I *hate* SCCS... */ - safe_strftime(buf, sizeof(buf) - 1, "%l:%" "M%p", tp); + safe_strftime(buf, sizeof(buf) - 1, "%l:%M%p", tp); else if (now - k->p_ustart_sec < DAYSPERWEEK * SECSPERDAY) - /* I *hate* SCCS... */ - safe_strftime(buf, sizeof(buf) - 1, "%a%" "I%p", tp); + safe_strftime(buf, sizeof(buf) - 1, "%a%I%p", tp); else safe_strftime(buf, sizeof(buf) - 1, "%e%b%y", tp); /* %e and %l can start with a space. */
CVS commit: src/bin/ps
Module Name:src Committed By: christos Date: Tue Apr 6 13:35:52 UTC 2021 Modified Files: src/bin/ps: print.c Log Message: - dedup code - add a safe_strftime() to handle error cases To generate a diff of this commit: cvs rdiff -u -r1.133 -r1.134 src/bin/ps/print.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/print.c diff -u src/bin/ps/print.c:1.133 src/bin/ps/print.c:1.134 --- src/bin/ps/print.c:1.133 Tue Apr 6 01:13:24 2021 +++ src/bin/ps/print.c Tue Apr 6 09:35:52 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: print.c,v 1.133 2021/04/06 05:13:24 simonb Exp $ */ +/* $NetBSD: print.c,v 1.134 2021/04/06 13:35:52 christos Exp $ */ /* * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ #if 0 static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; #else -__RCSID("$NetBSD: print.c,v 1.133 2021/04/06 05:13:24 simonb Exp $"); +__RCSID("$NetBSD: print.c,v 1.134 2021/04/06 13:35:52 christos Exp $"); #endif #endif /* not lint */ @@ -109,6 +109,14 @@ static time_t now; #define LSDEAD 6 #endif +static void __attribute__((__format__(__strftime__, 3, 0))) +safe_strftime(char *buf, size_t bufsiz, const char *fmt, +const struct tm *tp) +{ + if (tp == NULL || strftime(buf, bufsiz, fmt, tp) == 0) + strlcpy(buf, "-", sizeof(buf)); +} + static int iwidth(u_int64_t v) { @@ -793,12 +801,12 @@ started(struct pinfo *pi, VARENT *ve, en (void)time(); if (now - k->p_ustart_sec < SECSPERDAY) /* I *hate* SCCS... */ - (void)strftime(buf, sizeof(buf) - 1, "%l:%" "M%p", tp); + safe_strftime(buf, sizeof(buf) - 1, "%l:%" "M%p", tp); else if (now - k->p_ustart_sec < DAYSPERWEEK * SECSPERDAY) /* I *hate* SCCS... */ - (void)strftime(buf, sizeof(buf) - 1, "%a%" "I%p", tp); + safe_strftime(buf, sizeof(buf) - 1, "%a%" "I%p", tp); else - (void)strftime(buf, sizeof(buf) - 1, "%e%b%y", tp); + safe_strftime(buf, sizeof(buf) - 1, "%e%b%y", tp); /* %e and %l can start with a space. */ cp = buf; if (*cp == ' ') @@ -829,20 +837,17 @@ lstarted(struct pinfo *pi, VARENT *ve, e * XXX: The hardcoded "STARTED" string. Better or * worse than a "<= 7" or some other arbitary number? */ - if (v->width <= (int)strlen("STARTED")) { - (void)strftime(buf, sizeof(buf) -1, "%c", - localtime()); - strprintorsetwidth(v, buf, mode); + if (v->width > (int)sizeof("STARTED") - 1) { + return; } } else { if (!k->p_uvalid) { (void)printf("%*s", v->width, "-"); - } else { - (void)strftime(buf, sizeof(buf) -1, "%c", - localtime()); - strprintorsetwidth(v, buf, mode); + return; } } + safe_strftime(buf, sizeof(buf) - 1, "%c", localtime()); + strprintorsetwidth(v, buf, mode); } void
CVS commit: src/bin/ps
Module Name:src Committed By: simonb Date: Tue Apr 6 05:13:24 UTC 2021 Modified Files: src/bin/ps: print.c Log Message: Fix the column width calculation for the lstart column if an empty column header is specified. Fixes bug pointed out by Ted Spradley in https://mail-index.netbsd.org/netbsd-users/2021/04/05/msg026808.html . To generate a diff of this commit: cvs rdiff -u -r1.132 -r1.133 src/bin/ps/print.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/print.c diff -u src/bin/ps/print.c:1.132 src/bin/ps/print.c:1.133 --- src/bin/ps/print.c:1.132 Wed Jun 19 21:25:50 2019 +++ src/bin/ps/print.c Tue Apr 6 05:13:24 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: print.c,v 1.132 2019/06/19 21:25:50 kamil Exp $ */ +/* $NetBSD: print.c,v 1.133 2021/04/06 05:13:24 simonb Exp $ */ /* * Copyright (c) 2000, 2007 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ #if 0 static char sccsid[] = "@(#)print.c 8.6 (Berkeley) 4/16/94"; #else -__RCSID("$NetBSD: print.c,v 1.132 2019/06/19 21:25:50 kamil Exp $"); +__RCSID("$NetBSD: print.c,v 1.133 2021/04/06 05:13:24 simonb Exp $"); #endif #endif /* not lint */ @@ -815,22 +815,33 @@ lstarted(struct pinfo *pi, VARENT *ve, e char buf[100]; v = ve->var; - if (!k->p_uvalid) { + startt = k->p_ustart_sec; + + if (mode == WIDTHMODE) { /* - * Minimum width is less than header - we don't - * need to check it every time. + * We only need to set the width once, as we assume + * that all times are the same length. We do need to + * check against the header length as well, as "no + * header" mode for this variable will set the field + * width to the length of the header anyway (ref: the + * P1003.1-2004 comment in findvar()). + * + * XXX: The hardcoded "STARTED" string. Better or + * worse than a "<= 7" or some other arbitary number? */ - if (mode == PRINTMODE) + if (v->width <= (int)strlen("STARTED")) { + (void)strftime(buf, sizeof(buf) -1, "%c", + localtime()); + strprintorsetwidth(v, buf, mode); + } + } else { + if (!k->p_uvalid) { (void)printf("%*s", v->width, "-"); - return; - } - startt = k->p_ustart_sec; - - /* assume all times are the same length */ - if (mode != WIDTHMODE || v->width == 0) { - (void)strftime(buf, sizeof(buf) -1, "%c", - localtime()); - strprintorsetwidth(v, buf, mode); + } else { + (void)strftime(buf, sizeof(buf) -1, "%c", + localtime()); + strprintorsetwidth(v, buf, mode); + } } }
CVS commit: src/bin/ps
Module Name:src Committed By: simonb Date: Tue Apr 6 04:49:41 UTC 2021 Modified Files: src/bin/ps: Makefile Log Message: We only need -Wno-format-y2k for print.c . To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/bin/ps/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/Makefile diff -u src/bin/ps/Makefile:1.29 src/bin/ps/Makefile:1.30 --- src/bin/ps/Makefile:1.29 Sun Aug 14 10:53:17 2011 +++ src/bin/ps/Makefile Tue Apr 6 04:49:41 2021 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.29 2011/08/14 10:53:17 christos Exp $ +# $NetBSD: Makefile,v 1.30 2021/04/06 04:49:41 simonb Exp $ # @(#)Makefile 8.1 (Berkeley) 6/2/93 PROG= ps @@ -6,7 +6,6 @@ SRCS= fmt.c keyword.c nlist.c print.c p DPADD= ${LIBM} ${LIBKVM} LDADD= -lm -lkvm -CWARNFLAGS+= -Wno-format-y2k -COPTS.print.c = -Wno-format-nonliteral +COPTS.print.c = -Wno-format-nonliteral -Wno-format-y2k .include
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Sun Apr 4 13:24:07 UTC 2021 Modified Files: src/bin/sh: eval.c jobs.c jobs.h Log Message: Related to PR bin/48875 Correct an issue found by Oguz and reported in e-mail (on the bug-bash list initially!) with the code changed to deal with PR bin/48875 With: sh -c 'echo start at $SECONDS; (sleep 3 & (sleep 1& wait) ); echo end at $SECONDS' The shell should say "start at 0\nend at 1\n", but instead (before this fix, in -9 and HEAD, but not -8) does "start at 0\nend at 3\n" (Not in -8 as the 48875 changes were never pulled up)> There was an old problem, fixed years ago, which cause the same symptom, related to the way the jobs table was cleared (or not) in subshells, and it seemed like that might have resurfaced. But not so, the issue here is the sub-shell elimination, which was part of the 48875 "fix" (not really, it wasn't really a bug, just sub-optimal and unexpected behaviour). What the shell actually has been running in this case is: sh -c 'echo start at $SECONDS; (sleep 3 & sleep 1& wait ); echo end at $SECONDS' as the inner subshell was deemed unnecessary - all its parent would do is wait for its exit status, and then exit with that status - we may as well simply replace the current sub-shell with the new one, let it do its thing, and we're done... But not here, the running "sleep 3" will remain a child of that merged sub-shell, and the "wait" will thus wait for it, along with the sleep 1 which is all it should be seeing. For now, fix this by not eliminating a sub-shell if there are existing unwaited upon children in the current one. It might be possible to simply disregard the old child for the purposes of wait (and "jobs", etc, all cmds which look at the jobs table) but the bookkeeping required to make that work reliably is likely to take some time to get correct... Along with this fix comes a fix to DEBUG mode shells, which, in situations like this, could dump core in the debug code if the relevant tracing was enabled, and add a new trace for when the jobs table is cleared (which was added predating the discovery of the actual cause of this issue, but seems worth keeping.) Neither of these changes have any effect on shells compiled normally. XXX pullup -9 To generate a diff of this commit: cvs rdiff -u -r1.181 -r1.182 src/bin/sh/eval.c cvs rdiff -u -r1.109 -r1.110 src/bin/sh/jobs.c cvs rdiff -u -r1.23 -r1.24 src/bin/sh/jobs.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/eval.c diff -u src/bin/sh/eval.c:1.181 src/bin/sh/eval.c:1.182 --- src/bin/sh/eval.c:1.181 Thu Aug 20 23:09:56 2020 +++ src/bin/sh/eval.c Sun Apr 4 13:24:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: eval.c,v 1.181 2020/08/20 23:09:56 kre Exp $ */ +/* $NetBSD: eval.c,v 1.182 2021/04/04 13:24:07 kre Exp $ */ /*- * Copyright (c) 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95"; #else -__RCSID("$NetBSD: eval.c,v 1.181 2020/08/20 23:09:56 kre Exp $"); +__RCSID("$NetBSD: eval.c,v 1.182 2021/04/04 13:24:07 kre Exp $"); #endif #endif /* not lint */ @@ -566,7 +566,7 @@ evalsubshell(union node *n, int flags) flushout(outx); } INTOFF; - if ((!backgnd && flags & EV_EXIT && !have_traps()) || + if ((!backgnd && flags & EV_EXIT && !have_traps() && !anyjobs()) || forkshell(jp = makejob(n, 1), n, backgnd?FORK_BG:FORK_FG) == 0) { if (backgnd) flags &=~ EV_TESTED; Index: src/bin/sh/jobs.c diff -u src/bin/sh/jobs.c:1.109 src/bin/sh/jobs.c:1.110 --- src/bin/sh/jobs.c:1.109 Sun Aug 30 19:45:05 2020 +++ src/bin/sh/jobs.c Sun Apr 4 13:24:07 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: jobs.c,v 1.109 2020/08/30 19:45:05 kre Exp $ */ +/* $NetBSD: jobs.c,v 1.110 2021/04/04 13:24:07 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)jobs.c 8.5 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: jobs.c,v 1.109 2020/08/30 19:45:05 kre Exp $"); +__RCSID("$NetBSD: jobs.c,v 1.110 2021/04/04 13:24:07 kre Exp $"); #endif #endif /* not lint */ @@ -785,7 +785,7 @@ waitcmd(int argc, char **argv) VTRACE(DBG_WAIT, ("wait %s%s%sfound %d candidates (last %s)\n", any ? "-n " : "", *argptr ? *argptr : "", argptr[0] && argptr[1] ? "... " : " ", found, - job ? (job->ref ? job->ref : "") : "none")); + job && job->used ? (job->ref ? job->ref : "") : "none")); /* * If we were given a list of jobnums: @@ -1056,6 +1056,32 @@ getjob(const char *name, int noerror) } +/* + * Find out if there are any running (that is, unwaited upon) + * background children of the current shell. + * + * Return 1/0 (yes, no). + * + * Needed as we cannot optimise away sub-shell creation if + * we have such a child, or a "wait" in that sub-shell would + * observe the already existing job. +
CVS commit: src/bin/ksh
Module Name:src Committed By: christos Date: Tue Feb 23 01:31:30 UTC 2021 Modified Files: src/bin/ksh: siglist.sh Log Message: PR/56007: Greg A. Woods: ksh unable to execute ERR traps (probably since 2016/03/17 - i.e. 8.x and 9.x) To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/bin/ksh/siglist.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ksh/siglist.sh diff -u src/bin/ksh/siglist.sh:1.12 src/bin/ksh/siglist.sh:1.13 --- src/bin/ksh/siglist.sh:1.12 Thu Mar 17 09:59:02 2016 +++ src/bin/ksh/siglist.sh Mon Feb 22 20:31:30 2021 @@ -1,5 +1,5 @@ #!/bin/sh -# $NetBSD: siglist.sh,v 1.12 2016/03/17 13:59:02 christos Exp $ +# $NetBSD: siglist.sh,v 1.13 2021/02/23 01:31:30 christos Exp $ # # Script to generate a sorted, complete list of signals, suitable # for inclusion in trap.c as array initializer. @@ -21,16 +21,17 @@ CPP="${1-cc -E}" # The trap here to make up for a bug in bash (1.14.3(1)) that calls the trap (trap $trapsigs; echo '#include "sh.h"'; - echo ' { QwErTy SIGNALS , "DUMMY" , "hook for number of signals" },'; + echo ' { QwErTy /* dummy for sed sillies */ },'; ${SED} -e '/^[ ]*#/d' -e 's/^[ ]*\([^ ][^ ]*\)[ ][ ]*\(.*[^ ]\)[ ]*$/#ifdef SIG\1\ { QwErTy .signal = SIG\1 , .name = "\1", .mess = "\2" },\ #endif/') > $in -# work around for gcc 5 +echo ' { QwErTy .signal = SIGNALS , .name = "DUMMY", .mess = "hook to expand array to total signals" },' >> $in +# work around for gcc > 5 $CPP $in | grep -v '^#' | tr -d '\n' | ${SED} 's/},/},\ /g' > $out ${SED} -n 's/{ QwErTy/{/p' < $out | ${AWK} '{print NR, $0}' | sort -k 5n -k 1n | -${SED} 's/^[0-9]* //' | -${AWK} 'BEGIN { last=0; nsigs=0; } +${SED} -E -e 's/^[0-9]* //' -e 's/ +/ /' | +${AWK} 'BEGIN { last=0; } { if ($4 ~ /^[0-9][0-9]*$/ && $5 == ",") { n = $4;
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Tue Feb 16 15:30:26 UTC 2021 Modified Files: src/bin/sh: input.c Log Message: PR bin/55979 Correctly handle (ie: ignore completely) \0 chars (nuls) in the shell command input stream (script, dot file, or stdin). Previously nul chars were ignored correctly in the line in which they occurred, but would cause trailing chars of that line to reappear as the start of the following line. If there was just one \0 skipped, this would generally result in an extra \n in the sh input, which in most cases has no effect. With multiple \0's in a single line, more of the end of that line was duplicated into the following one. This usually manifested as a weird "command not found" error. Note that any \0 chars in the sh input make the script non-conforming, so fixing this is not crucial (no \0's should really ever be seen) but it was an obvious bug in the code, which was attempting to ignore nul chars (as do many other shells), so let it be fixed. XXX pullup -9 To generate a diff of this commit: cvs rdiff -u -r1.71 -r1.72 src/bin/sh/input.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/input.c diff -u src/bin/sh/input.c:1.71 src/bin/sh/input.c:1.72 --- src/bin/sh/input.c:1.71 Sat Feb 9 09:20:47 2019 +++ src/bin/sh/input.c Tue Feb 16 15:30:26 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: input.c,v 1.71 2019/02/09 09:20:47 kre Exp $ */ +/* $NetBSD: input.c,v 1.72 2021/02/16 15:30:26 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)input.c 8.3 (Berkeley) 6/9/95"; #else -__RCSID("$NetBSD: input.c,v 1.71 2019/02/09 09:20:47 kre Exp $"); +__RCSID("$NetBSD: input.c,v 1.72 2021/02/16 15:30:26 kre Exp $"); #endif #endif /* not lint */ @@ -90,6 +90,7 @@ struct parsefile { int fd; /* file descriptor (or -1 if string) */ int nleft; /* number of chars left in this line */ int lleft; /* number of chars left in this buffer */ + int nskip; /* number of \0's dropped in previous line */ const char *nextc; /* next char in buffer */ char *buf; /* input buffer */ struct strpush *strpush; /* for pushing strings at this level */ @@ -274,8 +275,13 @@ preadbuffer(void) parselleft = parsenleft = EOF_NLEFT; return PEOF; } + parsefile->nskip = 0; } + /* jump over slots for any \0 chars that were dropped */ + parsenextc += parsefile->nskip; + parsefile->nskip = 0; + /* p = (not const char *)parsenextc; */ p = parsefile->buf + (parsenextc - parsefile->buf); q = p; @@ -288,6 +294,7 @@ preadbuffer(void) switch (*p) { case '\0': p++; /* Skip nul */ + parsefile->nskip++; goto check; case '\t': @@ -306,7 +313,11 @@ preadbuffer(void) break; } - *q++ = *p++; + if (parsefile->nskip) + *q++ = *p++; + else + q = ++p; + check: if (--parselleft <= 0) { parsenleft = q - parsenextc - 1;
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Tue Feb 16 15:30:12 UTC 2021 Modified Files: src/bin/sh: exec.c Log Message: PR bin/55979 This fixes the MSAN detected reference to an unitialised variable (an unitialised field in a struct) which happens when a command is not found after a PATH search. Aside from skipping some known to be going to fail exec*() calls in some cases, the setting of the relevant field is irrelevant, so this problem makes no practical difference to the shell, or any shell script. XXX (maybe) pullup -9 To generate a diff of this commit: cvs rdiff -u -r1.54 -r1.55 src/bin/sh/exec.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/exec.c diff -u src/bin/sh/exec.c:1.54 src/bin/sh/exec.c:1.55 --- src/bin/sh/exec.c:1.54 Sat Aug 1 17:51:18 2020 +++ src/bin/sh/exec.c Tue Feb 16 15:30:12 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: exec.c,v 1.54 2020/08/01 17:51:18 kre Exp $ */ +/* $NetBSD: exec.c,v 1.55 2021/02/16 15:30:12 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)exec.c 8.4 (Berkeley) 6/8/95"; #else -__RCSID("$NetBSD: exec.c,v 1.54 2020/08/01 17:51:18 kre Exp $"); +__RCSID("$NetBSD: exec.c,v 1.55 2021/02/16 15:30:12 kre Exp $"); #endif #endif /* not lint */ @@ -683,6 +683,7 @@ loop: if (act & DO_ERR) outfmt(out2, "%s: %s\n", name, errmsg(e, E_EXEC)); entry->cmdtype = CMDUNKNOWN; + entry->u.index = idx + 1; return; builtin_success: @@ -704,8 +705,10 @@ success: entry->lineno = cmdp->lineno; entry->lno_frel = cmdp->fn_ln1; entry->u = cmdp->param; - } else + } else { entry->cmdtype = CMDUNKNOWN; + entry->u.index = -1; + } }
CVS commit: src/bin/df
Module Name:src Committed By: ginsbach Date: Wed Jan 6 20:38:09 UTC 2021 Modified Files: src/bin/df: df.1 Log Message: df: bump man page date To generate a diff of this commit: cvs rdiff -u -r1.55 -r1.56 src/bin/df/df.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/df/df.1 diff -u src/bin/df/df.1:1.55 src/bin/df/df.1:1.56 --- src/bin/df/df.1:1.55 Sun Jan 3 01:43:12 2021 +++ src/bin/df/df.1 Wed Jan 6 20:38:09 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: df.1,v 1.55 2021/01/03 01:43:12 ginsbach Exp $ +.\" $NetBSD: df.1,v 1.56 2021/01/06 20:38:09 ginsbach Exp $ .\" .\" Copyright (c) 1989, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" @(#)df.1 8.2 (Berkeley) 1/13/92 .\" -.Dd September 23, 2019 +.Dd January 2, 2021 .Dt DF 1 .Os .Sh NAME
CVS commit: src/bin/df
Module Name:src Committed By: ginsbach Date: Sun Jan 3 01:43:13 UTC 2021 Modified Files: src/bin/df: df.1 df.c Log Message: df: add grand total option Add a grand total option, -c, similar to the du(1) -c option. Adapted from the same option (-c) in FreeBSD df(1). To generate a diff of this commit: cvs rdiff -u -r1.54 -r1.55 src/bin/df/df.1 cvs rdiff -u -r1.97 -r1.98 src/bin/df/df.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/df/df.1 diff -u src/bin/df/df.1:1.54 src/bin/df/df.1:1.55 --- src/bin/df/df.1:1.54 Mon Sep 23 15:24:44 2019 +++ src/bin/df/df.1 Sun Jan 3 01:43:12 2021 @@ -1,4 +1,4 @@ -.\" $NetBSD: df.1,v 1.54 2019/09/23 15:24:44 christos Exp $ +.\" $NetBSD: df.1,v 1.55 2021/01/03 01:43:12 ginsbach Exp $ .\" .\" Copyright (c) 1989, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -37,7 +37,7 @@ .Nd display free disk space .Sh SYNOPSIS .Nm -.Op Fl aglnW +.Op Fl acglnW .Op Fl Ghkm | Fl ihkm | Fl Pk .Op Fl t Ar type .Op Ar file | Ar file_system ... @@ -72,6 +72,8 @@ Show all mount points, including those that were mounted with the .Dv MNT_IGNORE flag. +.It Fl c +Display a grand total for all shown mount points. .It Fl G Display all the fields of the structure(s) returned by .Xr statvfs 2 . Index: src/bin/df/df.c diff -u src/bin/df/df.c:1.97 src/bin/df/df.c:1.98 --- src/bin/df/df.c:1.97 Fri Aug 21 16:41:06 2020 +++ src/bin/df/df.c Sun Jan 3 01:43:12 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: df.c,v 1.97 2020/08/21 16:41:06 ryo Exp $ */ +/* $NetBSD: df.c,v 1.98 2021/01/03 01:43:12 ginsbach Exp $ */ /* * Copyright (c) 1980, 1990, 1993, 1994 @@ -45,7 +45,7 @@ __COPYRIGHT( #if 0 static char sccsid[] = "@(#)df.c 8.7 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: df.c,v 1.97 2020/08/21 16:41:06 ryo Exp $"); +__RCSID("$NetBSD: df.c,v 1.98 2021/01/03 01:43:12 ginsbach Exp $"); #endif #endif /* not lint */ @@ -67,6 +67,7 @@ __RCSID("$NetBSD: df.c,v 1.97 2020/08/21 #include static char *getmntpt(const char *); +static void addstat(struct statvfs *, const struct statvfs *); static void prtstat(const struct statvfs *, int); static int selected(const char *, size_t); static void maketypelist(char *); @@ -75,7 +76,7 @@ __dead static void usage(void); static void prthumanval(int64_t, int); static void prthuman(const struct statvfs *, int64_t, int64_t); -static int aflag, gflag, hflag, iflag, lflag, nflag, Pflag, Wflag; +static int aflag, cflag, gflag, hflag, iflag, lflag, nflag, Pflag, Wflag; static long usize; static char **typelist; @@ -87,7 +88,7 @@ int main(int argc, char *argv[]) { struct stat stbuf; - struct statvfs *mntbuf; + struct statvfs *mntbuf, totals; int ch, maxwidth, width; size_t i, mntcount; char *mntpt; @@ -95,11 +96,14 @@ main(int argc, char *argv[]) setprogname(argv[0]); (void)setlocale(LC_ALL, ""); - while ((ch = getopt(argc, argv, "aGghiklmnPt:W")) != -1) + while ((ch = getopt(argc, argv, "acGghiklmnPt:W")) != -1) switch (ch) { case 'a': aflag = 1; break; + case 'c': + cflag = 1; + break; case 'g': hflag = 0; usize = 1024 * 1024 * 1024; @@ -207,15 +211,28 @@ main(int argc, char *argv[]) } } + if (cflag) { + memset(, 0, sizeof(totals)); + totals.f_bsize = DEV_BSIZE; + strlcpy(totals.f_mntfromname, "total", + sizeof(totals.f_mntfromname)); + } + maxwidth = 0; for (i = 0; i < mntcount; i++) { width = (int)strlen(Wflag && mntbuf[i].f_mntfromlabel[0] ? mntbuf[i].f_mntfromlabel : mntbuf[i].f_mntfromname); if (width > maxwidth) maxwidth = width; + if (cflag) + addstat(, [i]); } for (i = 0; i < mntcount; i++) prtstat([i], maxwidth); + + if (cflag) + prtstat(, maxwidth); + return 0; } @@ -361,6 +378,22 @@ prthuman(const struct statvfs *sfsp, int (int64_t)(num) / (int64_t)((bs) / (fsbs)) : \ (int64_t)(num) * (int64_t)((fsbs) / (bs))) +static void +addstat(struct statvfs *totalfsp, const struct statvfs *sfsp) +{ + uint64_t frsize; + + frsize = sfsp->f_frsize / totalfsp->f_frsize; + totalfsp->f_blocks += sfsp->f_blocks * frsize; + totalfsp->f_bfree += sfsp->f_bfree * frsize; + totalfsp->f_bavail += sfsp->f_bavail * frsize; + totalfsp->f_bresvd += sfsp->f_bresvd * frsize; + totalfsp->f_files += sfsp->f_files; + totalfsp->f_ffree += sfsp->f_ffree; + totalfsp->f_favail += sfsp->f_favail; + totalfsp->f_fresvd += sfsp->f_fresvd; +} + /* * Print out status about a filesystem. */
CVS commit: src/bin/csh
Module Name:src Committed By: mlelstv Date: Sat Oct 17 08:46:02 UTC 2020 Modified Files: src/bin/csh: time.c Log Message: Print real maxrss value like other shells. To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/bin/csh/time.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/csh/time.c diff -u src/bin/csh/time.c:1.22 src/bin/csh/time.c:1.23 --- src/bin/csh/time.c:1.22 Thu Apr 23 07:54:53 2020 +++ src/bin/csh/time.c Sat Oct 17 08:46:02 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: time.c,v 1.22 2020/04/23 07:54:53 simonb Exp $ */ +/* $NetBSD: time.c,v 1.23 2020/10/17 08:46:02 mlelstv Exp $ */ /*- * Copyright (c) 1980, 1991, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)time.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: time.c,v 1.22 2020/04/23 07:54:53 simonb Exp $"); +__RCSID("$NetBSD: time.c,v 1.23 2020/10/17 08:46:02 mlelstv Exp $"); #endif #endif /* not lint */ @@ -182,7 +182,7 @@ prusage1(FILE *fp, const char *cp, int p (r0->ru_ixrss + r0->ru_idrss + r0->ru_isrss)) / t)); break; case 'M': /* max. Resident Set Size */ - (void)fprintf(fp, "%ld", r1->ru_maxrss / 2L); + (void)fprintf(fp, "%ld", r1->ru_maxrss); break; case 'O': /* FS blocks out */ (void)fprintf(fp, "%ld", r1->ru_oublock - r0->ru_oublock);
CVS commit: src/bin/csh
Module Name:src Committed By: christos Date: Fri Oct 2 17:33:14 UTC 2020 Modified Files: src/bin/csh: lex.c Log Message: undo previous for 'r' and 'e' modifiers; they should no go further than the last '/'. To generate a diff of this commit: cvs rdiff -u -r1.37 -r1.38 src/bin/csh/lex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/csh/lex.c diff -u src/bin/csh/lex.c:1.37 src/bin/csh/lex.c:1.38 --- src/bin/csh/lex.c:1.37 Wed Sep 30 13:51:10 2020 +++ src/bin/csh/lex.c Fri Oct 2 13:33:13 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lex.c,v 1.37 2020/09/30 17:51:10 christos Exp $ */ +/* $NetBSD: lex.c,v 1.38 2020/10/02 17:33:13 christos Exp $ */ /*- * Copyright (c) 1980, 1991, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)lex.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: lex.c,v 1.37 2020/09/30 17:51:10 christos Exp $"); +__RCSID("$NetBSD: lex.c,v 1.38 2020/10/02 17:33:13 christos Exp $"); #endif #endif /* not lint */ @@ -996,6 +996,7 @@ domod(Char *cp, int type) if ((c != ' ' && c != '\t') || type == 'q') *xp |= QUOTE; return (wp); + case 'h': case 't': wp = Strrchr(cp, '/'); @@ -1009,14 +1010,16 @@ domod(Char *cp, int type) case 'e': case 'r': - wp = Strrchr(cp, '.'); - if (wp == NULL) - return Strsave(type == 'r' ? cp : STRNULL); - if (type == 'e') - xp = Strsave(wp + 1); - else - xp = Strsave(cp), xp[wp - cp] = 0; - return (xp); + wp = Strend(cp); + for (wp--; wp >= cp && *wp != '/'; wp--) + if (*wp == '.') { + if (type == 'e') + xp = Strsave(wp + 1); + else + xp = Strsave(cp), xp[wp - cp] = 0; + return (xp); + } + return (Strsave(type == 'e' ? STRNULL : cp)); default: break;
CVS commit: src/bin/csh
Module Name:src Committed By: christos Date: Wed Sep 30 17:51:10 UTC 2020 Modified Files: src/bin/csh: lex.c Log Message: Fix % set x='a/b c/d.e' % echo $x:q:h To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/bin/csh/lex.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/csh/lex.c diff -u src/bin/csh/lex.c:1.36 src/bin/csh/lex.c:1.37 --- src/bin/csh/lex.c:1.36 Sat Aug 8 20:34:21 2020 +++ src/bin/csh/lex.c Wed Sep 30 13:51:10 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lex.c,v 1.36 2020/08/09 00:34:21 dholland Exp $ */ +/* $NetBSD: lex.c,v 1.37 2020/09/30 17:51:10 christos Exp $ */ /*- * Copyright (c) 1980, 1991, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)lex.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: lex.c,v 1.36 2020/08/09 00:34:21 dholland Exp $"); +__RCSID("$NetBSD: lex.c,v 1.37 2020/09/30 17:51:10 christos Exp $"); #endif #endif /* not lint */ @@ -998,28 +998,26 @@ domod(Char *cp, int type) return (wp); case 'h': case 't': - if (!any(short2str(cp), '/')) - return (type == 't' ? Strsave(cp) : 0); - wp = Strend(cp); - while (*--wp != '/') - continue; - if (type == 'h') - xp = Strsave(cp), xp[wp - cp] = 0; - else + wp = Strrchr(cp, '/'); + if (wp == NULL) + return Strsave(type == 't' ? cp : STRNULL); + if (type == 't') xp = Strsave(wp + 1); + else + xp = Strsave(cp), xp[wp - cp] = 0; return (xp); + case 'e': case 'r': - wp = Strend(cp); - for (wp--; wp >= cp && *wp != '/'; wp--) - if (*wp == '.') { - if (type == 'e') - xp = Strsave(wp + 1); - else - xp = Strsave(cp), xp[wp - cp] = 0; - return (xp); - } - return (Strsave(type == 'e' ? STRNULL : cp)); + wp = Strrchr(cp, '.'); + if (wp == NULL) + return Strsave(type == 'r' ? cp : STRNULL); + if (type == 'e') + xp = Strsave(wp + 1); + else + xp = Strsave(cp), xp[wp - cp] = 0; + return (xp); + default: break; }
CVS commit: src/bin/sh
Module Name:src Committed By: wiz Date: Fri Sep 18 07:21:26 UTC 2020 Modified Files: src/bin/sh: sh.1 Log Message: Remove superfluous Ed. To generate a diff of this commit: cvs rdiff -u -r1.228 -r1.229 src/bin/sh/sh.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/sh.1 diff -u src/bin/sh/sh.1:1.228 src/bin/sh/sh.1:1.229 --- src/bin/sh/sh.1:1.228 Fri Sep 18 06:48:28 2020 +++ src/bin/sh/sh.1 Fri Sep 18 07:21:26 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: sh.1,v 1.228 2020/09/18 06:48:28 kre Exp $ +.\" $NetBSD: sh.1,v 1.229 2020/09/18 07:21:26 wiz Exp $ .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" @@ -2618,7 +2618,6 @@ and also exporting the variables named and .Dq c , which is probably not as intended. -.Ed .Pp With no arguments the export command lists the names of all set exported variables,
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Fri Sep 18 06:48:28 UTC 2020 Modified Files: src/bin/sh: sh.1 Log Message: Correct an incorrectly quoted (unquoted, but should be) example used in the "local" built-in command description (pointed out by mrg@ via uwe@ in private e-mail). Add a description to the export command of why this quoting is required, and then refer to it from local and readonly (explained in export as that one comes first). Note that some shells parse export/local/readonly (and often more) as "declarative" commands, and this quoting isn't needed (provided the command name is literal and not the result of an expansion) making X=$Y type args not require quoting, as they often don't in a regular variable assignment (preceding, or not part of, another command). POSIX is going to allow, but not require, that behaviour. We do not implement it. To generate a diff of this commit: cvs rdiff -u -r1.227 -r1.228 src/bin/sh/sh.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/sh.1 diff -u src/bin/sh/sh.1:1.227 src/bin/sh/sh.1:1.228 --- src/bin/sh/sh.1:1.227 Tue Aug 25 19:42:02 2020 +++ src/bin/sh/sh.1 Fri Sep 18 06:48:28 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: sh.1,v 1.227 2020/08/25 19:42:02 kre Exp $ +.\" $NetBSD: sh.1,v 1.228 2020/09/18 06:48:28 kre Exp $ .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" @@ -31,7 +31,7 @@ .\" .\" @(#)sh.1 8.6 (Berkeley) 5/4/95 .\" -.Dd August 20, 2020 +.Dd September 18, 2020 .Dt SH 1 .\" everything except c o and s (keep them ordered) .ds flags abCEeFfhIiLmnpquVvXx @@ -2591,6 +2591,35 @@ same time it is exported (or unexported, .Pp .Dl export [-nx] name=value .Pp +Note that in such a usage, the +.Dq name=value +argument often needs to be quoted, +more often than is required of an assignment statement, +as, like with any other command, the command name and +arguments are all subject to the various expansions, +including filename expansion and field splitting, +before the +.Ic export +command is invoked. +With the default value for +.Dv IFS : +.Bd -unfilled -compact -offset indent +X='a b c' +export Y=$X +.Ed +the command invoked would be +.Dl "export Y=a b c" +exporting +.Dv Y , +with the value +.Dq a +and also exporting the variables named +.Dq b +and +.Dq c , +which is probably not as intended. +.Ed +.Pp With no arguments the export command lists the names of all set exported variables, or if @@ -3060,12 +3089,15 @@ Note that any variable references on the been expanded before .Ic local is executed, so expressions like -.Pp -.Dl "local -N X=${X}" +.Bd -unfilled -offset indent +local -N X="${X}" +.Ed .Pp are well defined, first $X is expanded, and then the command run is -.Pp -.Dl "local -N X=old-value-of-X" +.Dl "local -N X='old-value-of-X'" +See the description of the +.Ic export +built-in command for notes on why quoting the value is required. .Pp After arranging to preserve the old value and attributes, of .Dv X @@ -3269,6 +3301,10 @@ to be set at the same time it is marked .Pp .Dl readonly name=value .Pp +where the value often needs to be quoted, as explained for the +.Ic export +command. +.Pp With no arguments the .Ic readonly command lists the names of all set read only variables.
CVS commit: src/bin/kill
Module Name:src Committed By: wiz Date: Sun Aug 30 20:14:07 UTC 2020 Modified Files: src/bin/kill: kill.1 Log Message: Mark up path with Pa and use Ev for environment variable. To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/bin/kill/kill.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/kill/kill.1 diff -u src/bin/kill/kill.1:1.32 src/bin/kill/kill.1:1.33 --- src/bin/kill/kill.1:1.32 Sun Aug 30 19:41:39 2020 +++ src/bin/kill/kill.1 Sun Aug 30 20:14:07 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: kill.1,v 1.32 2020/08/30 19:41:39 kre Exp $ +.\" $NetBSD: kill.1,v 1.33 2020/08/30 20:14:07 wiz Exp $ .\" .\" Copyright (c) 1980, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -81,8 +81,10 @@ parameter or a signal number. .Pp If no operand is given, display the names of all the signals. -In /bin/kill, if the variable -.Dv POSIXLY_CORRECT +In +.Pa /bin/kill , +if the variable +.Ev POSIXLY_CORRECT is set in the environment, this uses the POSIX specified format, otherwise a slightly more pleasing layout is used. .It Fl signal_name
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Sun Aug 30 19:45:05 UTC 2020 Modified Files: src/bin/sh: jobs.c Log Message: Since "struct job" gained a pgrp member some time ago now, use it instead of simply assuming that the pid of the first (leftmost) process in a pipeline is the pgrp - someday we may switch things around and create pipelines right to left instead, which has several advantages, but which would invalidate the assumption which was being made here. To generate a diff of this commit: cvs rdiff -u -r1.108 -r1.109 src/bin/sh/jobs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/jobs.c diff -u src/bin/sh/jobs.c:1.108 src/bin/sh/jobs.c:1.109 --- src/bin/sh/jobs.c:1.108 Thu Aug 20 23:03:17 2020 +++ src/bin/sh/jobs.c Sun Aug 30 19:45:05 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: jobs.c,v 1.108 2020/08/20 23:03:17 kre Exp $ */ +/* $NetBSD: jobs.c,v 1.109 2020/08/30 19:45:05 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)jobs.c 8.5 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: jobs.c,v 1.108 2020/08/20 23:03:17 kre Exp $"); +__RCSID("$NetBSD: jobs.c,v 1.109 2020/08/30 19:45:05 kre Exp $"); #endif #endif /* not lint */ @@ -971,7 +971,7 @@ getjobpgrp(const char *name) jp = getjob(name, 1); if (jp == 0) return 0; - return -jp->ps[0].pid; + return -jp->pgrp; } /*
CVS commit: src/bin/kill
Module Name:src Committed By: kre Date: Sun Aug 30 19:41:39 UTC 2020 Modified Files: src/bin/kill: kill.1 Log Message: Note that negative pid args are permitted (indicating to send to the pgrp abs(pid)) and indicate that -- is (strictly) needed if the first pid arg (there often is only one) is negative - though this implementation works without it if a signal to send has been explicitly given, but whereas 'kill 1234" is valid (send SIGTERM to pid 1234) "kill -1234" will generate a usage error from the attempt to send signal 1234 to nothing, to send SIGTERM to pgrp 1234 it needs to be "kill -- -1234" (or "kill -s term -1234"). While here do a couple of markup improvements, and allow for the possibility that users might be running the builtin kill from some shell other than csh or sh. To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/bin/kill/kill.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/kill/kill.1 diff -u src/bin/kill/kill.1:1.31 src/bin/kill/kill.1:1.32 --- src/bin/kill/kill.1:1.31 Sun Aug 30 16:10:40 2020 +++ src/bin/kill/kill.1 Sun Aug 30 19:41:39 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: kill.1,v 1.31 2020/08/30 16:10:40 kre Exp $ +.\" $NetBSD: kill.1,v 1.32 2020/08/30 19:41:39 kre Exp $ .\" .\" Copyright (c) 1980, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -32,7 +32,7 @@ .\" .\" @(#)kill.1 8.2 (Berkeley) 4/28/95 .\" -.Dd May 6, 2020 +.Dd August 30, 2020 .Dt KILL 1 .Os .Sh NAME @@ -95,7 +95,9 @@ of the default .Dv TERM . .El .Pp -The following pids have special meanings: +The following +.Ar pid Ns s +have special meanings: .Bl -tag -width Ds -compact .It -1 If superuser, broadcast the signal to all processes; otherwise broadcast @@ -104,6 +106,24 @@ to all processes belonging to the user. Broadcast the signal to all processes in the current process group belonging to the user. .El +Any other negative +.Ar pid +is interpreted as the negative of a process group identifier, +and the signal is sent to all members of that group. +.Pp +Note that while not required by this implementation, +if the first +.Ar pid +operand is negative, it should be preceded by the +.Dq \&-- +end of options indicator, to avoid the +.Ar pid +being treated as yet more options. +That is always required if no specific signal is specified +and the first +.Ar pid +is negative, or that pid would be treated as the +.Ar signal_number . .Pp Some of the more commonly used signals: .Bl -tag -width Ds -compact @@ -143,9 +163,9 @@ so process id's are not as often used as .Nm arguments. See -.Xr csh 1 -or +.Xr csh 1 , .Xr sh 1 +or the man page for the shell in use for details. .Sh DIAGNOSTICS .Ex -std
CVS commit: src/bin/kill
Module Name:src Committed By: kre Date: Sun Aug 30 19:35:10 UTC 2020 Modified Files: src/bin/kill: kill.c Log Message: Every integer that fits within a pid_t is a potential "pid" arg to kill. That means we cannot use (pid_t)-1 as an error indicator, as that's a valid pid to use (described as working in kill(1) - yet it wasn't working in /bin/kill (nor sh's builtin kill, which is essentially the same code). This is even required to work by POSIX. So change processnum() (the parser/validator for the pid args) to take a pointer to a pid_t and return the pid that way, leaving the return value of the (now int) function to indicate just ok/error. While here, fix the validation a little ('' is no longer an accepted alias for 0) and in case of an error from kill(2) have the error message indicate whether the kill was targeted at a pid of a pgrp. To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/bin/kill/kill.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/kill/kill.c diff -u src/bin/kill/kill.c:1.31 src/bin/kill/kill.c:1.32 --- src/bin/kill/kill.c:1.31 Sun Aug 30 16:10:40 2020 +++ src/bin/kill/kill.c Sun Aug 30 19:35:09 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kill.c,v 1.31 2020/08/30 16:10:40 kre Exp $ */ +/* $NetBSD: kill.c,v 1.32 2020/08/30 19:35:09 kre Exp $ */ /* * Copyright (c) 1988, 1993, 1994 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19 #if 0 static char sccsid[] = "@(#)kill.c 8.4 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: kill.c,v 1.31 2020/08/30 16:10:40 kre Exp $"); +__RCSID("$NetBSD: kill.c,v 1.32 2020/08/30 19:35:09 kre Exp $"); #endif #endif /* not lint */ @@ -66,7 +66,7 @@ int killcmd(int, char *argv[]); __dead static void nosig(const char *); void printsignals(FILE *, int); static int signum(const char *); -static pid_t processnum(const char *); +static int processnum(const char *, pid_t *); __dead static void usage(void); int @@ -177,6 +177,7 @@ main(int argc, char *argv[]) for (errors = 0; argc; argc--, argv++) { #ifdef SHELL extern int getjobpgrp(const char *); + if (*argv[0] == '%') { pid = getjobpgrp(*argv); if (pid == 0) { @@ -186,13 +187,13 @@ main(int argc, char *argv[]) } } else #endif - if ((pid = processnum(*argv)) == (pid_t)-1) { + if (processnum(*argv, ) != 0) { errors = 1; continue; } if (kill(pid, numsig) == -1) { - warn("%s", *argv); + warn("%s %s", pid < -1 ? "pgrp" : "pid", *argv); errors = 1; } #ifdef SHELL @@ -226,22 +227,24 @@ signum(const char *sn) return (int)n; } -static pid_t -processnum(const char *s) +static int +processnum(const char *s, pid_t *pid) { intmax_t n; char *ep; + errno = 0; n = strtoimax(s, , 10); /* check for correctly parsed number */ - if (*ep || n == INTMAX_MIN || n == INTMAX_MAX || (pid_t)n != n || - n == -1) { - warnx("illegal process%s id: %s", (n < 0 ? " group" : ""), s); - n = -1; + if (ep == s || *ep || n == INTMAX_MIN || n == INTMAX_MAX || + (pid_t)n != n || errno != 0) { + warnx("illegal process%s id: '%s'", (n < 0 ? " group" : ""), s); + return -1; } - return (pid_t)n; + *pid = (pid_t)n; + return 0; } static void
CVS commit: src/bin/kill
Module Name:src Committed By: kre Date: Sun Aug 30 16:10:40 UTC 2020 Modified Files: src/bin/kill: kill.1 kill.c Log Message: Use the POSIX specified format if POSIXLY_CORRECT is set in the environment, rather than the nicer layout that is normally used. Note this applies to /bin/kill only, the builtin kill in sh uses its "posix" option for the same purpose, the one in csh only ever uses POSIX format. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/bin/kill/kill.1 src/bin/kill/kill.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/kill/kill.1 diff -u src/bin/kill/kill.1:1.30 src/bin/kill/kill.1:1.31 --- src/bin/kill/kill.1:1.30 Wed May 6 13:13:50 2020 +++ src/bin/kill/kill.1 Sun Aug 30 16:10:40 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: kill.1,v 1.30 2020/05/06 13:13:50 kre Exp $ +.\" $NetBSD: kill.1,v 1.31 2020/08/30 16:10:40 kre Exp $ .\" .\" Copyright (c) 1980, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -81,6 +81,10 @@ parameter or a signal number. .Pp If no operand is given, display the names of all the signals. +In /bin/kill, if the variable +.Dv POSIXLY_CORRECT +is set in the environment, this uses the POSIX specified format, +otherwise a slightly more pleasing layout is used. .It Fl signal_name A symbolic signal name specifying the signal to be sent instead of the default Index: src/bin/kill/kill.c diff -u src/bin/kill/kill.c:1.30 src/bin/kill/kill.c:1.31 --- src/bin/kill/kill.c:1.30 Wed Dec 12 20:22:43 2018 +++ src/bin/kill/kill.c Sun Aug 30 16:10:40 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: kill.c,v 1.30 2018/12/12 20:22:43 kre Exp $ */ +/* $NetBSD: kill.c,v 1.31 2020/08/30 16:10:40 kre Exp $ */ /* * Copyright (c) 1988, 1993, 1994 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19 #if 0 static char sccsid[] = "@(#)kill.c 8.4 (Berkeley) 4/28/95"; #else -__RCSID("$NetBSD: kill.c,v 1.30 2018/12/12 20:22:43 kre Exp $"); +__RCSID("$NetBSD: kill.c,v 1.31 2020/08/30 16:10:40 kre Exp $"); #endif #endif /* not lint */ @@ -267,7 +267,9 @@ printsignals(FILE *fp, int len) int nl, pad; const char *name; int termwidth = 80; + int posix; + posix = getenv("POSIXLY_CORRECT") != 0; if ((name = getenv("COLUMNS")) != 0) termwidth = atoi(name); else if (isatty(fileno(fp))) { @@ -278,6 +280,8 @@ printsignals(FILE *fp, int len) } pad = (len | 7) + 1 - len; + if (posix && pad) + pad = 1; for (sig = 0; (sig = signalnext(sig)) != 0; ) { name = signalname(sig); @@ -297,6 +301,8 @@ printsignals(FILE *fp, int len) len += nl + pad; pad = (nl | 7) + 1 - nl; + if (posix && pad) + pad = 1; fprintf(fp, "%s", name); }
CVS commit: src/bin/ps
Module Name:src Committed By: simonb Date: Wed Aug 26 10:54:13 UTC 2020 Modified Files: src/bin/ps: nlist.c Log Message: Don't rely on the USPACE kernel define as a fallback if the vm.uspace sysctl fails. We've got bigger problems if the sysctl fail anyway. To generate a diff of this commit: cvs rdiff -u -r1.27 -r1.28 src/bin/ps/nlist.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ps/nlist.c diff -u src/bin/ps/nlist.c:1.27 src/bin/ps/nlist.c:1.28 --- src/bin/ps/nlist.c:1.27 Mon Nov 28 08:19:23 2016 +++ src/bin/ps/nlist.c Wed Aug 26 10:54:12 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: nlist.c,v 1.27 2016/11/28 08:19:23 rin Exp $ */ +/* $NetBSD: nlist.c,v 1.28 2020/08/26 10:54:12 simonb Exp $ */ /* * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -63,7 +63,7 @@ #if 0 static char sccsid[] = "@(#)nlist.c 8.4 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: nlist.c,v 1.27 2016/11/28 08:19:23 rin Exp $"); +__RCSID("$NetBSD: nlist.c,v 1.28 2020/08/26 10:54:12 simonb Exp $"); #endif #endif /* not lint */ @@ -113,9 +113,7 @@ int uspace;/* kernel USPACE value */ #ifndef MAXSLP #define MAXSLP 20 #endif -#ifndef USPACE -#define USPACE (getpagesize()) -#endif +#define DEF_USPACE (getpagesize()) #define kread(x, v) \ kvm_read(kd, psnl[x].n_value, (char *), sizeof v) != sizeof(v) @@ -177,7 +175,7 @@ donlist_sysctl(void) mib[1] = KERN_FSCALE; size = sizeof(fscale); if (sysctl(mib, 2, , , NULL, 0)) { - warn("fscale"); + warn("sysctl kern.fscale"); eval = 1; fscale = FSCALE; } @@ -186,7 +184,7 @@ donlist_sysctl(void) mib[1] = HW_PHYSMEM64; size = sizeof(memsize); if (sysctl(mib, 2, , , NULL, 0)) { - warn("avail_start"); + warn("sysctl hw.avail_start"); eval = 1; mempages = MEMPAGES; } else @@ -196,7 +194,7 @@ donlist_sysctl(void) mib[1] = KERN_CCPU; size = sizeof(xccpu); if (sysctl(mib, 2, , , NULL, 0)) { - warn("ccpu"); + warn("sysctl kern.ccpu"); eval = 1; log_ccpu = LOG_CCPU; } else @@ -206,7 +204,7 @@ donlist_sysctl(void) mib[1] = VM_MAXSLP; size = sizeof(maxslp); if (sysctl(mib, 2, , , NULL, 0)) { - warn("maxslp"); + warn("sysctl vm.maxslp"); eval = 1; maxslp = MAXSLP; } @@ -215,9 +213,9 @@ donlist_sysctl(void) mib[1] = VM_USPACE; size = sizeof(uspace); if (sysctl(mib, 2, , , NULL, 0)) { - warn("uspace"); + warn("sysctl vm.uspace"); eval = 1; - uspace = USPACE; + uspace = DEF_USPACE; } }
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Tue Aug 25 19:42:02 UTC 2020 Modified Files: src/bin/sh: sh.1 Log Message: Idiot typo, generated by an idiot, fixed by the same one. To generate a diff of this commit: cvs rdiff -u -r1.226 -r1.227 src/bin/sh/sh.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/sh.1 diff -u src/bin/sh/sh.1:1.226 src/bin/sh/sh.1:1.227 --- src/bin/sh/sh.1:1.226 Fri Aug 21 08:14:45 2020 +++ src/bin/sh/sh.1 Tue Aug 25 19:42:02 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: sh.1,v 1.226 2020/08/21 08:14:45 wiz Exp $ +.\" $NetBSD: sh.1,v 1.227 2020/08/25 19:42:02 kre Exp $ .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" @@ -1861,7 +1861,7 @@ can result in multiple fields being prod not because of field-splitting. If unquoted, each field produced by -.Dv $ \" $@ +.Dv $@ \" $@ is subject to field splitting. .El .Pp
CVS commit: src/bin/df
Module Name:src Committed By: ryo Date: Fri Aug 21 16:41:06 UTC 2020 Modified Files: src/bin/df: df.c Log Message: - Bump Size/Used/Avail from 10 to 12, and iUsed/iAvail from 8 to 10 for double-digit terabyte storage. - set the field width to the optimal, if "-h" is specified. - if blocksize is greater than M or G, reduce the size field width. To generate a diff of this commit: cvs rdiff -u -r1.96 -r1.97 src/bin/df/df.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/df/df.c diff -u src/bin/df/df.c:1.96 src/bin/df/df.c:1.97 --- src/bin/df/df.c:1.96 Fri Aug 21 16:40:02 2020 +++ src/bin/df/df.c Fri Aug 21 16:41:06 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: df.c,v 1.96 2020/08/21 16:40:02 ryo Exp $ */ +/* $NetBSD: df.c,v 1.97 2020/08/21 16:41:06 ryo Exp $ */ /* * Copyright (c) 1980, 1990, 1993, 1994 @@ -45,7 +45,7 @@ __COPYRIGHT( #if 0 static char sccsid[] = "@(#)df.c 8.7 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: df.c,v 1.96 2020/08/21 16:40:02 ryo Exp $"); +__RCSID("$NetBSD: df.c,v 1.97 2020/08/21 16:41:06 ryo Exp $"); #endif #endif /* not lint */ @@ -79,8 +79,9 @@ static int aflag, gflag, hflag, iflag, static long usize; static char **typelist; -#define WIDTH_INODE 8 -#define WIDTH_BLKSIZE 10 +#define WIDTH_INODE 10 +#define WIDTH_BLKSIZE 12 +static int blksize_width = WIDTH_BLKSIZE; int main(int argc, char *argv[]) @@ -346,9 +347,9 @@ static void prthuman(const struct statvfs *sfsp, int64_t used, int64_t bavail) { - prthumanval((int64_t)(sfsp->f_blocks * sfsp->f_frsize), WIDTH_BLKSIZE); - prthumanval((int64_t)(used * sfsp->f_frsize), 1 + WIDTH_BLKSIZE); - prthumanval((int64_t)(bavail * sfsp->f_frsize), 1 + WIDTH_BLKSIZE); + prthumanval((int64_t)(sfsp->f_blocks * sfsp->f_frsize), blksize_width); + prthumanval((int64_t)(used * sfsp->f_frsize), 1 + blksize_width); + prthumanval((int64_t)(bavail * sfsp->f_frsize), 1 + blksize_width); } /* @@ -447,10 +448,19 @@ prtstat(const struct statvfs *sfsp, int if (hflag) { header = "Size"; headerlen = (int)strlen(header); +blksize_width = 6; } else header = getbsize(, ); break; } + + if (blocksize >= 1024 * 1024) + blksize_width -= 3; + if (blocksize >= 1024 * 1024 * 1024) + blksize_width -= 3; + if (blksize_width < headerlen) + blksize_width = headerlen; + if (Pflag) { /* * either: @@ -466,9 +476,9 @@ prtstat(const struct statvfs *sfsp, int } else { (void)printf("%-*.*s %*s %*s %*s %%Cap", maxwidth, maxwidth, "Filesystem", - WIDTH_BLKSIZE, header, - WIDTH_BLKSIZE, "Used", - WIDTH_BLKSIZE, "Avail"); + blksize_width, header, + blksize_width, "Used", + blksize_width, "Avail"); if (iflag) { (void)printf(" %*s %*s %%iCap", WIDTH_INODE, "iUsed", @@ -510,10 +520,10 @@ prtstat(const struct statvfs *sfsp, int prthuman(sfsp, used, bavail); else (void)printf("%*" PRId64 " %*" PRId64 " %*" PRId64, - WIDTH_BLKSIZE, + blksize_width, fsbtoblk(sfsp->f_blocks, sfsp->f_frsize, blocksize), - WIDTH_BLKSIZE, fsbtoblk(used, sfsp->f_frsize, blocksize), - WIDTH_BLKSIZE, fsbtoblk(bavail, sfsp->f_frsize, blocksize)); + blksize_width, fsbtoblk(used, sfsp->f_frsize, blocksize), + blksize_width, fsbtoblk(bavail, sfsp->f_frsize, blocksize)); (void)printf(" %3s%%", availblks == 0 ? full : strspct(pb, sizeof(pb), used, availblks, 0));
CVS commit: src/bin/df
Module Name:src Committed By: ryo Date: Fri Aug 21 16:40:02 UTC 2020 Modified Files: src/bin/df: df.c Log Message: field width of blocksize and inode can be changed by #define To generate a diff of this commit: cvs rdiff -u -r1.95 -r1.96 src/bin/df/df.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/df/df.c diff -u src/bin/df/df.c:1.95 src/bin/df/df.c:1.96 --- src/bin/df/df.c:1.95 Sun Sep 22 22:59:37 2019 +++ src/bin/df/df.c Fri Aug 21 16:40:02 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: df.c,v 1.95 2019/09/22 22:59:37 christos Exp $ */ +/* $NetBSD: df.c,v 1.96 2020/08/21 16:40:02 ryo Exp $ */ /* * Copyright (c) 1980, 1990, 1993, 1994 @@ -45,7 +45,7 @@ __COPYRIGHT( #if 0 static char sccsid[] = "@(#)df.c 8.7 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: df.c,v 1.95 2019/09/22 22:59:37 christos Exp $"); +__RCSID("$NetBSD: df.c,v 1.96 2020/08/21 16:40:02 ryo Exp $"); #endif #endif /* not lint */ @@ -72,13 +72,16 @@ static int selected(const char *, size_ static void maketypelist(char *); static size_t regetmntinfo(struct statvfs **, size_t); __dead static void usage(void); -static void prthumanval(int64_t, const char *); +static void prthumanval(int64_t, int); static void prthuman(const struct statvfs *, int64_t, int64_t); static int aflag, gflag, hflag, iflag, lflag, nflag, Pflag, Wflag; static long usize; static char **typelist; +#define WIDTH_INODE 8 +#define WIDTH_BLKSIZE 10 + int main(int argc, char *argv[]) { @@ -328,7 +331,7 @@ regetmntinfo(struct statvfs **mntbufp, s } static void -prthumanval(int64_t bytes, const char *pad) +prthumanval(int64_t bytes, int width) { char buf[6]; @@ -336,16 +339,16 @@ prthumanval(int64_t bytes, const char *p bytes, "", HN_AUTOSCALE, HN_B | HN_NOSPACE | HN_DECIMAL); - (void)printf("%s %6s", pad, buf); + (void)printf("%*s", width, buf); } static void prthuman(const struct statvfs *sfsp, int64_t used, int64_t bavail) { - prthumanval((int64_t)(sfsp->f_blocks * sfsp->f_frsize), " "); - prthumanval((int64_t)(used * sfsp->f_frsize), ""); - prthumanval((int64_t)(bavail * sfsp->f_frsize), ""); + prthumanval((int64_t)(sfsp->f_blocks * sfsp->f_frsize), WIDTH_BLKSIZE); + prthumanval((int64_t)(used * sfsp->f_frsize), 1 + WIDTH_BLKSIZE); + prthumanval((int64_t)(bavail * sfsp->f_frsize), 1 + WIDTH_BLKSIZE); } /* @@ -461,12 +464,16 @@ prtstat(const struct statvfs *sfsp, int (void)printf("Filesystem %s Used Available Capacity " "Mounted on\n", header); } else { - (void)printf("%-*.*s %s Used Avail %%Cap", - maxwidth - (headerlen - 10), - maxwidth - (headerlen - 10), - "Filesystem", header); - if (iflag) -(void)printf("iUsed iAvail %%iCap"); + (void)printf("%-*.*s %*s %*s %*s %%Cap", + maxwidth, maxwidth, "Filesystem", + WIDTH_BLKSIZE, header, + WIDTH_BLKSIZE, "Used", + WIDTH_BLKSIZE, "Avail"); + if (iflag) { +(void)printf(" %*s %*s %%iCap", +WIDTH_INODE, "iUsed", +WIDTH_INODE, "iAvail"); + } (void)printf(" Mounted on\n"); } } @@ -502,18 +509,20 @@ prtstat(const struct statvfs *sfsp, int if (hflag) prthuman(sfsp, used, bavail); else - (void)printf("%10" PRId64 " %10" PRId64 " %10" PRId64, + (void)printf("%*" PRId64 " %*" PRId64 " %*" PRId64, + WIDTH_BLKSIZE, fsbtoblk(sfsp->f_blocks, sfsp->f_frsize, blocksize), - fsbtoblk(used, sfsp->f_frsize, blocksize), - fsbtoblk(bavail, sfsp->f_frsize, blocksize)); + WIDTH_BLKSIZE, fsbtoblk(used, sfsp->f_frsize, blocksize), + WIDTH_BLKSIZE, fsbtoblk(bavail, sfsp->f_frsize, blocksize)); (void)printf(" %3s%%", availblks == 0 ? full : strspct(pb, sizeof(pb), used, availblks, 0)); if (iflag) { inodes = sfsp->f_files; used = inodes - sfsp->f_ffree; - (void)printf(" %8jd %8jd %4s%%", - (intmax_t)used, (intmax_t)sfsp->f_ffree, + (void)printf(" %*jd %*jd %4s%%", + WIDTH_INODE, (intmax_t)used, + WIDTH_INODE, (intmax_t)sfsp->f_ffree, inodes == 0 ? (used == 0 ? empty : full) : strspct(pb, sizeof(pb), used, inodes, 0)); }
CVS commit: src/bin/sh
Module Name:src Committed By: wiz Date: Fri Aug 21 08:14:45 UTC 2020 Modified Files: src/bin/sh: sh.1 Log Message: Remove unmatched .El and mark up signal name with Dv. To generate a diff of this commit: cvs rdiff -u -r1.225 -r1.226 src/bin/sh/sh.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/sh.1 diff -u src/bin/sh/sh.1:1.225 src/bin/sh/sh.1:1.226 --- src/bin/sh/sh.1:1.225 Thu Aug 20 23:19:34 2020 +++ src/bin/sh/sh.1 Fri Aug 21 08:14:45 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: sh.1,v 1.225 2020/08/20 23:19:34 kre Exp $ +.\" $NetBSD: sh.1,v 1.226 2020/08/21 08:14:45 wiz Exp $ .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" @@ -1133,7 +1133,6 @@ implicitly by an empty directory name, o If a directory searched contains an executable file with the same name as the command given, the search terminates, and that program is executed. -.El .Ss Command Exit Status Each command has an exit status that can influence the behavior of other shell commands. @@ -3584,7 +3583,9 @@ command, or function, upon receiving sig .Pp .Dl Ic eval Qo \&$( trap -P QUIT \&) Qc .Pp -Parse and execute the action that would be invoked were a SIGQUIT received. +Parse and execute the action that would be invoked were a +.Dv SIGQUIT +received. .Pp .Dl trap 1 2 .Pp
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Thu Aug 20 23:19:34 UTC 2020 Modified Files: src/bin/sh: sh.1 Log Message: Man page enhancements. Better describe the command search procedure. Document "trap -P" Describe what works as a function name. More accurate description of reserved word recognition. Be more accurate about when field splittng happens after expansions (and in particular note that tilde expansions are not subject to field splitting). Be clear that "$@" is not field split, it simply produces multiple fields as part of its expansion (hence IFS is irrelevant to this), but if used as $@ (unquoted) each field produced is potentially subject to field splitting. Other minor wording changes. To generate a diff of this commit: cvs rdiff -u -r1.224 -r1.225 src/bin/sh/sh.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/sh.1 diff -u src/bin/sh/sh.1:1.224 src/bin/sh/sh.1:1.225 --- src/bin/sh/sh.1:1.224 Thu Feb 20 18:24:20 2020 +++ src/bin/sh/sh.1 Thu Aug 20 23:19:34 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: sh.1,v 1.224 2020/02/20 18:24:20 pgoyette Exp $ +.\" $NetBSD: sh.1,v 1.225 2020/08/20 23:19:34 kre Exp $ .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" @@ -31,7 +31,7 @@ .\" .\" @(#)sh.1 8.6 (Berkeley) 5/4/95 .\" -.Dd February 20, 2020 +.Dd August 20, 2020 .Dt SH 1 .\" everything except c o and s (keep them ordered) .ds flags abCEeFfhIiLmnpquVvXx @@ -815,8 +815,11 @@ converted, it is treated as if it had be .Ss Reserved Words .\" Reserved words are words that have special meaning to the -shell and are recognized at the beginning of a line and -after a control operator. +shell and are recognized, +if completely unquoted, +at the beginning of a line, +after a control operator, +and where the syntax of a command specifically requires a reserved word. The following are reserved words: .Bl -column while while while while -offset indent .It Ic \&! Ta Ic \&{ Ta Ic \&} Ta Ic case @@ -1108,16 +,17 @@ number as a .\" .Ss Path Search .\" -When locating a command, the shell first looks to see if it has a shell -function by that name. -Then it looks for a built-in command by that name. -If a built-in command is not found, one of two things happen: -.Bl -enum -.It -Command names containing a slash are simply executed without performing -any searches. -.It -Otherwise, the shell searches each entry in +When locating a command, +command names containing a slash +.Pq Sq \&/ +are simply executed without performing any searches. +.Pp +If there is no slash in the name, +the shell first looks to see if it is a special built-in command, +if not it looks to see if there is a shell function by that name. +If that fails it looks for an ordinary built-in command. +If a none of these searches located the command +the shell searches each entry in .Ev PATH in turn for the command. The value of the @@ -1541,7 +1545,34 @@ The syntax of a function definition is .Dl Ar name Ns Ic \&() Ar command Op Ar redirect No ... .Pp A function definition is an executable statement; when executed it -installs a function named name and returns an exit status of zero. +installs a function named +.Ar name +and returns an exit status of zero. +To be portable, and standards compliant, the name must use the same +syntax as a variable name, (see +.Sx "Variables and Parameters" +below). +As an extension, this shell allows almost all characters in +.Ar name +.Po +the exception is slash +.Pq Sq \&/ +as there is no way to invoke a function with a name containing +a slash +.Pc . +Including quoting, whitespace, and operator characters requires +that the word be quoted. +The +.Ar name +is subject to quote removal, but no other expansions. +Because of implementation issues, +unquoted dollar signs +.Pq Sq \&$ +and backquotes +.Pq Sq \&` +are prohibited, +but can be included in a function name by use of quoting. +.Pp The command is normally a list enclosed between .Dq { and @@ -1748,12 +1779,15 @@ The order of word expansion is: .Bl -enum .It Tilde Expansion, Parameter Expansion, Command Substitution, -Arithmetic Expansion (these all occur at the same time). +Arithmetic Expansion (these all occur at the same time, and the +result of any of these expansions is not rescanned for further +instances of the expansion, or any of the others). .It -Field Splitting is performed on fields -generated by step (1) unless the +Unless the .Ev IFS -variable is null. +variable has an empty value, +Field Splitting is performed on fields +generated by step (1) except for Tilde Expansion. .It Pathname Expansion (unless set .Fl f @@ -1821,8 +1855,15 @@ If a parameter expansion occurs inside d pathname expansion is not performed on the results of the expansion; .It field splitting is not performed on the results of the -expansion, with the exception of the special
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Thu Aug 20 23:09:56 UTC 2020 Modified Files: src/bin/sh: eval.c trap.c Log Message: Be less conservative about when we do clear_traps() when we have traps_invalid (that is, when we actually nuke the parent shell's caught traps in a subshell). This allows more reasonable use of "trap -p" (and similar) in subshells than existed before (and in particular, that command can be in a function now - there can also be several related commands like traps=$(trap -p INT; trap -p QUIT; trap -p HUP) A side effect of all of this is that (eval "$(trap -p)"; ...) now allows copying caught traps into a subshell environment, if desired. Also att the ksh93 variant (the one not picked by POSIX as it isn't generally as useful) of "trap -p" (but call it "trap -P" which extracts just the trap action for named signals (giving more than one is usually undesirable). This allows eval "$(trap -P INT)" to run the action for SIGINT traps, without needing to attempt to parse the "trap -p" output. To generate a diff of this commit: cvs rdiff -u -r1.180 -r1.181 src/bin/sh/eval.c cvs rdiff -u -r1.54 -r1.55 src/bin/sh/trap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/eval.c diff -u src/bin/sh/eval.c:1.180 src/bin/sh/eval.c:1.181 --- src/bin/sh/eval.c:1.180 Thu May 14 08:34:17 2020 +++ src/bin/sh/eval.c Thu Aug 20 23:09:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: eval.c,v 1.180 2020/05/14 08:34:17 msaitoh Exp $ */ +/* $NetBSD: eval.c,v 1.181 2020/08/20 23:09:56 kre Exp $ */ /*- * Copyright (c) 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95"; #else -__RCSID("$NetBSD: eval.c,v 1.180 2020/05/14 08:34:17 msaitoh Exp $"); +__RCSID("$NetBSD: eval.c,v 1.181 2020/08/20 23:09:56 kre Exp $"); #endif #endif /* not lint */ @@ -280,8 +280,10 @@ evaltree(union node *n, int flags) next = NULL; CTRACE(DBG_EVAL, ("pid %d, evaltree(%p: %s(%d), %#x) called\n", getpid(), n, NODETYPENAME(n->type), n->type, flags)); + /* if (n->type != NCMD && traps_invalid) free_traps(); + */ switch (n->type) { case NSEMI: evaltree(n->nbinary.ch1, sflags); @@ -302,6 +304,8 @@ evaltree(union node *n, int flags) next = n->nbinary.ch2; break; case NREDIR: + if (traps_invalid) +free_traps(); evalredir(n, flags); break; case NSUBSHELL: @@ -309,9 +313,13 @@ evaltree(union node *n, int flags) do_etest = !(flags & EV_TESTED); break; case NBACKGND: + if (traps_invalid) +free_traps(); evalsubshell(n, flags); break; case NIF: { + if (traps_invalid) +free_traps(); evaltree(n->nif.test, EV_TESTED); if (nflag || evalskip) goto out1; @@ -325,15 +333,23 @@ evaltree(union node *n, int flags) } case NWHILE: case NUNTIL: + if (traps_invalid) +free_traps(); evalloop(n, sflags); break; case NFOR: + if (traps_invalid) +free_traps(); evalfor(n, sflags); break; case NCASE: + if (traps_invalid) +free_traps(); evalcase(n, sflags); break; case NDEFUN: + if (traps_invalid) +free_traps(); CTRACE(DBG_EVAL, ("Defining fn %s @%d%s\n", n->narg.text, n->narg.lineno, fnline1 ? " LINENO=1" : "")); @@ -350,6 +366,8 @@ evaltree(union node *n, int flags) exitstatus = 1; break; case NPIPE: + if (traps_invalid) +free_traps(); evalpipe(n); do_etest = !(flags & EV_TESTED); break; @@ -1043,6 +1061,10 @@ evalcommand(union node *cmd, int flgs, s * command eval trap * eval command trap * without zapping the traps completely, in all other cases we do. + * Function calls also do not zap the traps (but commands they execute + * probably will) - this allows a function like + * trapstate() { trap -p; } + * called as save_traps=$(trapstate). * * The test here permits eval "anything" but when evalstring() comes * back here again, the "anything" will be validated. @@ -1055,6 +1077,7 @@ evalcommand(union node *cmd, int flgs, s * trapcmd() takes care of doing free_traps() if it is needed there. */ if (traps_invalid && + cmdentry.cmdtype != CMDFUNCTION && ((cmdentry.cmdtype!=CMDSPLBLTIN && cmdentry.cmdtype!=CMDBUILTIN) || (cmdentry.u.bltin != trapcmd && cmdentry.u.bltin != evalcmd))) free_traps(); Index: src/bin/sh/trap.c diff -u src/bin/sh/trap.c:1.54 src/bin/sh/trap.c:1.55 --- src/bin/sh/trap.c:1.54 Thu Aug 20 16:15:50 2020 +++ src/bin/sh/trap.c Thu Aug 20 23:09:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.54 2020/08/20 16:15:50 kre Exp $ */ +/* $NetBSD: trap.c,v 1.55 2020/08/20 23:09:56 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)trap.c 8.5 (Berkeley) 6/5/95"; #else -__RCSID("$NetBSD: trap.c,v 1.54 2020/08/20 16:15:50 kre Exp $"); +__RCSID("$NetBSD: trap.c,v 1.55
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Thu Aug 20 23:03:17 UTC 2020 Modified Files: src/bin/sh: jobs.c Log Message: Add lots of comments explaining what is happening in here. Also enhance some of the DEBUG mode trace output (nothing visible in a normal shell build). A couple of very minor code changes that no-one should ever notice (eg: one less wait() call in the case that there is nothing pending). To generate a diff of this commit: cvs rdiff -u -r1.107 -r1.108 src/bin/sh/jobs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/jobs.c diff -u src/bin/sh/jobs.c:1.107 src/bin/sh/jobs.c:1.108 --- src/bin/sh/jobs.c:1.107 Fri Feb 7 02:06:12 2020 +++ src/bin/sh/jobs.c Thu Aug 20 23:03:17 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: jobs.c,v 1.107 2020/02/07 02:06:12 kre Exp $ */ +/* $NetBSD: jobs.c,v 1.108 2020/08/20 23:03:17 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)jobs.c 8.5 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: jobs.c,v 1.107 2020/02/07 02:06:12 kre Exp $"); +__RCSID("$NetBSD: jobs.c,v 1.108 2020/08/20 23:03:17 kre Exp $"); #endif #endif /* not lint */ @@ -380,6 +380,18 @@ restartjob(struct job *jp) return; INTOFF; for (e = i = 0; i < jp->nprocs; i++) { + /* + * Don't touch a process we already waited for and collected + * exit status, that pid may have been reused for something + * else - even another of our jobs + */ + if (jp->ps[i].status != -1 && !WIFSTOPPED(jp->ps[i].status)) + continue; + + /* + * Otherwise tell it to continue, if it worked, we're done + * (we signal the whole process group) + */ if (killpg(jp->ps[i].pid, SIGCONT) != -1) break; if (e == 0 && errno != ESRCH) @@ -387,6 +399,11 @@ restartjob(struct job *jp) } if (i >= jp->nprocs) error("Cannot continue job (%s)", strerror(e ? e : ESRCH)); + + /* + * Now change state of all stopped processes in the job to running + * If there were any, the job is now running as well. + */ for (ps = jp->ps, i = jp->nprocs ; --i >= 0 ; ps++) { if (WIFSTOPPED(ps->status)) { VTRACE(DBG_JOBS, ( @@ -570,10 +587,10 @@ showjobs(struct output *out, int mode) CTRACE(DBG_JOBS, ("showjobs(%x) called\n", mode)); - /* If not even one one job changed, there is nothing to do */ - gotpid = dowait(WSILENT, NULL, NULL); - while (dowait(WSILENT, NULL, NULL) > 0) - continue; + /* Collect everything pending in the kernel */ + if ((gotpid = dowait(WSILENT, NULL, NULL)) > 0) + while (dowait(WSILENT, NULL, NULL) > 0) + continue; #ifdef JOBS /* * Check if we are not in our foreground group, and if not @@ -813,19 +830,25 @@ waitcmd(int argc, char **argv) /* * There is at least 1 job running, so we can - * safely wait() for something to exit. + * safely wait() (blocking) for something to exit. */ if (jp->state == JOBRUNNING) { job = NULL; if ((i = dowait(WBLOCK|WNOFREE, NULL, )) == -1) return 128 + lastsig(); - if (job == NULL) /* an interloper */ + /* + * This happens if an interloper has died + * (eg: a child of the executable that exec'd us) + * Simply go back and start all over again + * (this is rare). + */ + if (job == NULL) continue; /* - * one of the job's processes exited, - * but there are more + * one of the reported job's processes exited, + * but there are more still running, back for more */ if (job->state == JOBRUNNING) continue; @@ -1314,7 +1337,17 @@ waitforjob(struct job *jp) /* - * Wait for a process to terminate. + * Wait for a process (any process) to terminate. + * + * If "job" is given (not NULL), then its jobcontrol status (and mflag) + * are used to determine if we wait for stopping/continuing processes or + * only terminating ones, and the decision whether to report to stdout + * or not varies depending what happened, and whether the affected job + * is the one that was requested or not. + * + * If "changed" is not NULL, then the job which changed because a + * process terminated/stopped will be reported by setting *changed, + * if there is any such job, otherwise we set *changed = NULL. */ STATIC int @@ -1327,53 +1360,123 @@ dowait(int flags, struct job *job, struc struct job *thisjob; int done; int stopped; + int err; - VTRACE(DBG_JOBS|DBG_PROCS, ("dowait(%x) called\n", flags)); + VTRACE(DBG_JOBS|DBG_PROCS, ("dowait(%x) called for job %d%s\n", + flags, (job ? job-jobtab+1 : 0), changed ? " [report change]":"")); if (changed != NULL) *changed = NULL; + /* + * First deal with the kernel, collect info on any (one) of our + * children that has changed state since we last asked. + * (loop if we're interrupted by a signal that we aren't processing) + */ do { + err = 0; pid = waitproc(flags & WBLOCK, job, ); - VTRACE(DBG_JOBS|DBG_PROCS, ("wait returns pid %d,
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Thu Aug 20 16:15:50 UTC 2020 Modified Files: src/bin/sh: trap.c Log Message: Whitespace. NFCI. To generate a diff of this commit: cvs rdiff -u -r1.53 -r1.54 src/bin/sh/trap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/trap.c diff -u src/bin/sh/trap.c:1.53 src/bin/sh/trap.c:1.54 --- src/bin/sh/trap.c:1.53 Mon Dec 9 00:14:30 2019 +++ src/bin/sh/trap.c Thu Aug 20 16:15:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.53 2019/12/09 00:14:30 kre Exp $ */ +/* $NetBSD: trap.c,v 1.54 2020/08/20 16:15:50 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)trap.c 8.5 (Berkeley) 6/5/95"; #else -__RCSID("$NetBSD: trap.c,v 1.53 2019/12/09 00:14:30 kre Exp $"); +__RCSID("$NetBSD: trap.c,v 1.54 2020/08/20 16:15:50 kre Exp $"); #endif #endif /* not lint */ @@ -115,7 +115,7 @@ signame_to_signum(const char *p) if (strcasecmp(p, "exit") == 0 ) return 0; - + i = signalnumber(p); if (i == 0) i = -1; @@ -153,7 +153,7 @@ printsignals(struct output *out, int len outc(' ', out); for (n = 1; n < NSIG; n++) { outfmt(out, "%s", trap_signame(n)); - if ((n == NSIG/2) || n == (NSIG - 1)) + if ((n == NSIG/2) || n == (NSIG - 1)) outstr("\n", out); else outc(' ', out); @@ -580,7 +580,7 @@ setsignal(int signo, int vforked) switch (action) { case S_DFL: sigact = SIG_DFL; break; - case S_CATCH: sigact = onsig; break; + case S_CATCH: sigact = onsig; break; case S_IGN: sigact = SIG_IGN; break; } @@ -694,7 +694,7 @@ onsig(int signo) if (signo == SIGINT && (traps_invalid || trap[SIGINT] == NULL)) { VTRACE(DBG_SIG, ("onsig(SIGINT), doing it now\n")); - if (suppressint && !in_dotrap) + if (suppressint && !in_dotrap) intpending = 1; else onint(); @@ -841,7 +841,7 @@ exitshell_savedstatus(void) sigset_t sigs; CTRACE(DBG_ERRS|DBG_PROCS|DBG_CMDS|DBG_TRAP, - ("pid %d: exitshell_savedstatus()%s $?=%d xs=%d dt=%d ts=%d\n", + ("pid %d: exitshell_savedstatus()%s $?=%d xs=%d dt=%d ts=%d\n", getpid(), exiting ? " exiting" : "", exitstatus, exiting_status, in_dotrap, last_trapsig));
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Wed Aug 19 22:41:47 UTC 2020 Modified Files: src/bin/sh: parser.c Log Message: For now, probably forever, prohibit unquoted $ and ` in the names of functions being defined (they can still be included if quoted). If we parsed the way POSIX specifies (leaving the exact input text of $ and ` expansions unaltered, until required to be expanded) this would not be needed, as the name of a function being defined does not underbo parameter, command, or arith expansions, so xxx$3() { : ; } would just work. But for many reasons we don't do that (and are unlikely to ever, though maintaing both forms might be an option someday) - which led to very obscure behaviour (if sh were compiled in DEBUG mode, even an abort()) and certainly nothing useful. So just prohibit these uses for now. (A portable function name must be a "name" so this makes no difference at all to posix compat applications/scripts). A doc update is pending (the updated sh.1 also contains updates in other areas not yet appropriate to commit). To generate a diff of this commit: cvs rdiff -u -r1.170 -r1.171 src/bin/sh/parser.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/parser.c diff -u src/bin/sh/parser.c:1.170 src/bin/sh/parser.c:1.171 --- src/bin/sh/parser.c:1.170 Thu May 14 08:34:17 2020 +++ src/bin/sh/parser.c Wed Aug 19 22:41:47 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: parser.c,v 1.170 2020/05/14 08:34:17 msaitoh Exp $ */ +/* $NetBSD: parser.c,v 1.171 2020/08/19 22:41:47 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)parser.c 8.7 (Berkeley) 5/16/95"; #else -__RCSID("$NetBSD: parser.c,v 1.170 2020/05/14 08:34:17 msaitoh Exp $"); +__RCSID("$NetBSD: parser.c,v 1.171 2020/08/19 22:41:47 kre Exp $"); #endif #endif /* not lint */ @@ -666,6 +666,18 @@ simplecmd(union node **rpp, union node * /* We have a function */ consumetoken(TRP); funclinno = plinno; + /* + * Make sure there are no unquoted $'s in the + * name (allowing those, not expanding them, + * simply treating '$' as a character, is desireable + * but the parser has converted them to CTLxxx + * chars, and that's not what we want + * + * Fortunately here the user can simply quote + * the name to avoid this restriction. + */ + if (!noexpand(n->narg.text)) +synerror("Bad function name (use quotes)"); rmescapes(n->narg.text); if (strchr(n->narg.text, '/')) synerror("Bad function name");
CVS commit: src/bin/csh
Module Name:src Committed By: dholland Date: Sun Aug 9 00:53:38 UTC 2020 Modified Files: src/bin/csh: csh.c Log Message: Use the right size for several calloc calls. When allocating for a Char **, it should use sizeof(Char *), not sizeof(Char **). This doesn't actually affect the results except on DS9000 though :-) (part 2, the instance in this file was as far as I can tell inexplicably missed by CVS on the first go...) To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/bin/csh/csh.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/csh/csh.c diff -u src/bin/csh/csh.c:1.52 src/bin/csh/csh.c:1.53 --- src/bin/csh/csh.c:1.52 Sun Aug 9 00:51:12 2020 +++ src/bin/csh/csh.c Sun Aug 9 00:53:38 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: csh.c,v 1.52 2020/08/09 00:51:12 dholland Exp $ */ +/* $NetBSD: csh.c,v 1.53 2020/08/09 00:53:38 dholland Exp $ */ /*- * Copyright (c) 1980, 1991, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = "@(#)csh.c 8.2 (Berkeley) 10/12/93"; #else -__RCSID("$NetBSD: csh.c,v 1.52 2020/08/09 00:51:12 dholland Exp $"); +__RCSID("$NetBSD: csh.c,v 1.53 2020/08/09 00:53:38 dholland Exp $"); #endif #endif /* not lint */ @@ -697,7 +697,7 @@ importpath(Char *cp) * i+2 where i is the number of colons in the path. There are i+1 * directories in the path plus we need room for a zero terminator. */ -pv = xcalloc((size_t) (i + 2), sizeof(Char **)); +pv = xcalloc((size_t) (i + 2), sizeof(*pv)); dp = cp; i = 0; if (*dp)
CVS commit: src/bin/csh
Module Name:src Committed By: dholland Date: Sun Aug 9 00:51:13 UTC 2020 Modified Files: src/bin/csh: csh.c Log Message: Clarify some comments. To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/bin/csh/csh.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/csh/csh.c diff -u src/bin/csh/csh.c:1.51 src/bin/csh/csh.c:1.52 --- src/bin/csh/csh.c:1.51 Sun Aug 9 00:22:53 2020 +++ src/bin/csh/csh.c Sun Aug 9 00:51:12 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: csh.c,v 1.51 2020/08/09 00:22:53 dholland Exp $ */ +/* $NetBSD: csh.c,v 1.52 2020/08/09 00:51:12 dholland Exp $ */ /*- * Copyright (c) 1980, 1991, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = "@(#)csh.c 8.2 (Berkeley) 10/12/93"; #else -__RCSID("$NetBSD: csh.c,v 1.51 2020/08/09 00:22:53 dholland Exp $"); +__RCSID("$NetBSD: csh.c,v 1.52 2020/08/09 00:51:12 dholland Exp $"); #endif #endif /* not lint */ @@ -845,13 +845,12 @@ srcunit(int unit, int onlyown, int hflg) int i; /* We made it to the new state... free up its storage */ - /* This code could get run twice but free doesn't care */ - /* XXX yes it does */ for (i = 0; i < fblocks; i++) free(fbuf[i]); free(fbuf); /* Reset input arena */ + /* (note that this clears fbuf and fblocks) */ (void)memcpy(, , sizeof(B)); (void)close(SHIN), SHIN = oSHIN;
CVS commit: src/bin/csh
Module Name:src Committed By: dholland Date: Sun Aug 9 00:34:21 UTC 2020 Modified Files: src/bin/csh: dir.c lex.c parse.c Log Message: Use the right size for several calloc calls. When allocating for a Char **, it should use sizeof(Char *), not sizeof(Char **). This doesn't actually affect the results except on DS9000 though :-) To generate a diff of this commit: cvs rdiff -u -r1.34 -r1.35 src/bin/csh/dir.c cvs rdiff -u -r1.35 -r1.36 src/bin/csh/lex.c cvs rdiff -u -r1.20 -r1.21 src/bin/csh/parse.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/csh/dir.c diff -u src/bin/csh/dir.c:1.34 src/bin/csh/dir.c:1.35 --- src/bin/csh/dir.c:1.34 Sun Aug 9 00:22:53 2020 +++ src/bin/csh/dir.c Sun Aug 9 00:34:21 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.34 2020/08/09 00:22:53 dholland Exp $ */ +/* $NetBSD: dir.c,v 1.35 2020/08/09 00:34:21 dholland Exp $ */ /*- * Copyright (c) 1980, 1991, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)dir.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: dir.c,v 1.34 2020/08/09 00:22:53 dholland Exp $"); +__RCSID("$NetBSD: dir.c,v 1.35 2020/08/09 00:34:21 dholland Exp $"); #endif #endif /* not lint */ @@ -147,7 +147,7 @@ dset(Char *dp) * other junk characters glob will fail. */ -vec = xmalloc((size_t)(2 * sizeof(Char **))); +vec = xmalloc(2 * sizeof(*vec)); vec[0] = Strsave(dp); vec[1] = 0; setq(STRcwd, vec, ); Index: src/bin/csh/lex.c diff -u src/bin/csh/lex.c:1.35 src/bin/csh/lex.c:1.36 --- src/bin/csh/lex.c:1.35 Sun Aug 9 00:22:53 2020 +++ src/bin/csh/lex.c Sun Aug 9 00:34:21 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lex.c,v 1.35 2020/08/09 00:22:53 dholland Exp $ */ +/* $NetBSD: lex.c,v 1.36 2020/08/09 00:34:21 dholland Exp $ */ /*- * Copyright (c) 1980, 1991, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)lex.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: lex.c,v 1.35 2020/08/09 00:22:53 dholland Exp $"); +__RCSID("$NetBSD: lex.c,v 1.36 2020/08/09 00:34:21 dholland Exp $"); #endif #endif /* not lint */ @@ -1453,7 +1453,8 @@ again: if (buf >= fblocks) { Char **nfbuf; - nfbuf = xcalloc((size_t) (fblocks + 2), sizeof(char **)); + /* XXX the cast is needed because fblocks is signed */ + nfbuf = xcalloc((size_t)(fblocks + 2), sizeof(*nfbuf)); if (fbuf) { (void)blkcpy(nfbuf, fbuf); free(fbuf); @@ -1623,7 +1624,7 @@ settell(void) return; if (lseek(SHIN, (off_t) 0, SEEK_CUR) < 0 || errno == ESPIPE) return; -fbuf = xcalloc(2, sizeof(Char **)); +fbuf = xcalloc(2, sizeof(*fbuf)); fblocks = 1; fbuf[0] = xcalloc(BUFSIZE, sizeof(Char)); fseekp = fbobp = feobp = lseek(SHIN, (off_t) 0, SEEK_CUR); Index: src/bin/csh/parse.c diff -u src/bin/csh/parse.c:1.20 src/bin/csh/parse.c:1.21 --- src/bin/csh/parse.c:1.20 Sun Aug 9 00:22:53 2020 +++ src/bin/csh/parse.c Sun Aug 9 00:34:21 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.20 2020/08/09 00:22:53 dholland Exp $ */ +/* $NetBSD: parse.c,v 1.21 2020/08/09 00:34:21 dholland Exp $ */ /*- * Copyright (c) 1980, 1991, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)parse.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: parse.c,v 1.20 2020/08/09 00:22:53 dholland Exp $"); +__RCSID("$NetBSD: parse.c,v 1.21 2020/08/09 00:34:21 dholland Exp $"); #endif #endif /* not lint */ @@ -509,7 +509,8 @@ again: if (n < 0) n = 0; t = xcalloc(1, sizeof(*t)); -av = xcalloc((size_t)(n + 1), sizeof(Char **)); +/* XXX the cast is needed because n is signed */ +av = xcalloc((size_t)(n + 1), sizeof(*av)); t->t_dcom = av; n = 0; if (p2->word[0] == ')')
CVS commit: src/bin/csh
Module Name:src Committed By: dholland Date: Sun Aug 9 00:22:53 UTC 2020 Modified Files: src/bin/csh: csh.c dir.c func.c lex.c parse.c proc.c Log Message: Don't cast the value returned from *malloc. No change to compiler output. To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/bin/csh/csh.c cvs rdiff -u -r1.33 -r1.34 src/bin/csh/dir.c cvs rdiff -u -r1.43 -r1.44 src/bin/csh/func.c cvs rdiff -u -r1.34 -r1.35 src/bin/csh/lex.c cvs rdiff -u -r1.19 -r1.20 src/bin/csh/parse.c cvs rdiff -u -r1.39 -r1.40 src/bin/csh/proc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/csh/csh.c diff -u src/bin/csh/csh.c:1.50 src/bin/csh/csh.c:1.51 --- src/bin/csh/csh.c:1.50 Fri Apr 3 18:11:29 2020 +++ src/bin/csh/csh.c Sun Aug 9 00:22:53 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: csh.c,v 1.50 2020/04/03 18:11:29 joerg Exp $ */ +/* $NetBSD: csh.c,v 1.51 2020/08/09 00:22:53 dholland Exp $ */ /*- * Copyright (c) 1980, 1991, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = "@(#)csh.c 8.2 (Berkeley) 10/12/93"; #else -__RCSID("$NetBSD: csh.c,v 1.50 2020/04/03 18:11:29 joerg Exp $"); +__RCSID("$NetBSD: csh.c,v 1.51 2020/08/09 00:22:53 dholland Exp $"); #endif #endif /* not lint */ @@ -697,7 +697,7 @@ importpath(Char *cp) * i+2 where i is the number of colons in the path. There are i+1 * directories in the path plus we need room for a zero terminator. */ -pv = (Char **)xcalloc((size_t) (i + 2), sizeof(Char **)); +pv = xcalloc((size_t) (i + 2), sizeof(Char **)); dp = cp; i = 0; if (*dp) @@ -1211,7 +1211,7 @@ process(int catch) * Made it! */ freelex(); - freesyn((struct command *) savet), savet = NULL; + freesyn(savet), savet = NULL; } resexit(osetexit); savet = t; Index: src/bin/csh/dir.c diff -u src/bin/csh/dir.c:1.33 src/bin/csh/dir.c:1.34 --- src/bin/csh/dir.c:1.33 Fri Apr 3 18:11:29 2020 +++ src/bin/csh/dir.c Sun Aug 9 00:22:53 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.33 2020/04/03 18:11:29 joerg Exp $ */ +/* $NetBSD: dir.c,v 1.34 2020/08/09 00:22:53 dholland Exp $ */ /*- * Copyright (c) 1980, 1991, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)dir.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: dir.c,v 1.33 2020/04/03 18:11:29 joerg Exp $"); +__RCSID("$NetBSD: dir.c,v 1.34 2020/08/09 00:22:53 dholland Exp $"); #endif #endif /* not lint */ @@ -128,7 +128,7 @@ dinit(Char *hp) } } -dp = (struct directory *)xcalloc(1, sizeof(struct directory)); +dp = xcalloc(1, sizeof(*dp)); dp->di_name = cp; dp->di_count = 0; dhead.di_next = dhead.di_prev = dp; @@ -363,7 +363,7 @@ dochngd(Char **v, struct command *t) } else cp = dfollow(*v); -dp = (struct directory *)xcalloc(1, sizeof(struct directory)); +dp = xcalloc(1, sizeof(*dp)); dp->di_name = cp; dp->di_count = 0; dp->di_next = dcwd->di_next; @@ -510,7 +510,7 @@ dopushd(Char **v, struct command *t) Char *ccp; ccp = dfollow(*v); - dp = (struct directory *)xcalloc(1, sizeof(struct directory)); + dp = xcalloc(1, sizeof(*dp)); dp->di_name = ccp; dp->di_count = 0; dp->di_prev = dcwd; Index: src/bin/csh/func.c diff -u src/bin/csh/func.c:1.43 src/bin/csh/func.c:1.44 --- src/bin/csh/func.c:1.43 Sun Jan 6 01:22:50 2019 +++ src/bin/csh/func.c Sun Aug 9 00:22:53 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: func.c,v 1.43 2019/01/06 01:22:50 christos Exp $ */ +/* $NetBSD: func.c,v 1.44 2020/08/09 00:22:53 dholland Exp $ */ /*- * Copyright (c) 1980, 1991, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)func.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: func.c,v 1.43 2019/01/06 01:22:50 christos Exp $"); +__RCSID("$NetBSD: func.c,v 1.44 2020/08/09 00:22:53 dholland Exp $"); #endif #endif /* not lint */ @@ -414,7 +414,7 @@ doforeach(Char **v, struct command *t) v = globall(v); if (v == 0) stderror(ERR_NAME | ERR_NOMATCH); -nwp = (struct whyle *) xcalloc(1, sizeof *nwp); +nwp = xcalloc(1, sizeof *nwp); nwp->w_fe = nwp->w_fe0 = v; gargv = 0; btell(>w_start); @@ -452,7 +452,7 @@ dowhile(Char **v, struct command *t) stderror(ERR_NAME | ERR_EXPRESSION); if (!again) { struct whyle *nwp = - (struct whyle *)xcalloc(1, sizeof(*nwp)); + xcalloc(1, sizeof(*nwp)); nwp->w_start = lineloc; nwp->w_end.type = F_SEEK; Index: src/bin/csh/lex.c diff -u src/bin/csh/lex.c:1.34 src/bin/csh/lex.c:1.35 --- src/bin/csh/lex.c:1.34 Fri Feb 1 08:29:03 2019 +++ src/bin/csh/lex.c Sun Aug 9 00:22:53 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: lex.c,v 1.34 2019/02/01 08:29:03 mrg Exp $ */ +/* $NetBSD: lex.c,v 1.35 2020/08/09 00:22:53 dholland Exp $ */ /*- * Copyright (c) 1980, 1991, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)lex.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: lex.c,v 1.34
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Sat Aug 1 17:56:56 UTC 2020 Modified Files: src/bin/sh: expand.c Log Message: Remove a redundant set of parentheses that were added (along with a extra && or || or something ... forgotten now) as part a failed attempt to fix an earlier bug (later fixed a better way) - when the extra test (never committed) was removed, the now-redundant parentheses got forgotten... NFC. To generate a diff of this commit: cvs rdiff -u -r1.137 -r1.138 src/bin/sh/expand.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/expand.c diff -u src/bin/sh/expand.c:1.137 src/bin/sh/expand.c:1.138 --- src/bin/sh/expand.c:1.137 Thu Feb 13 05:19:05 2020 +++ src/bin/sh/expand.c Sat Aug 1 17:56:56 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: expand.c,v 1.137 2020/02/13 05:19:05 kre Exp $ */ +/* $NetBSD: expand.c,v 1.138 2020/08/01 17:56:56 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)expand.c 8.5 (Berkeley) 5/15/95"; #else -__RCSID("$NetBSD: expand.c,v 1.137 2020/02/13 05:19:05 kre Exp $"); +__RCSID("$NetBSD: expand.c,v 1.138 2020/08/01 17:56:56 kre Exp $"); #endif #endif /* not lint */ @@ -309,7 +309,7 @@ argstr(const char *p, int flag) had_dol_at = 0; break; case CTLESC: - if ((quotes || ISCTL(*p))) + if (quotes || ISCTL(*p)) STPUTC(c, expdest); c = *p++; STPUTC(c, expdest);
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Sat Aug 1 17:51:18 UTC 2020 Modified Files: src/bin/sh: exec.c Log Message: PR bin/55526 Fix a bug that has existed since the "command" command was added in 2003. "command foo" would cause the definition of a function "foo" to be lost (not freed, simply discarded) if "foo" is (in addition to being a function) a filesystem command. The case where "foo" is a builtin was handled. For now, when a function exists with the same name as a filesystem command, the latter can never appear in the command hash table, and when used (which can only be via "command foo", just "foo" finds the function) will always result in a full PATH search. XXX pullup everything (from NetBSD 2.0 onwards). (really -8 and -9) To generate a diff of this commit: cvs rdiff -u -r1.53 -r1.54 src/bin/sh/exec.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/exec.c diff -u src/bin/sh/exec.c:1.53 src/bin/sh/exec.c:1.54 --- src/bin/sh/exec.c:1.53 Wed Jul 25 14:42:50 2018 +++ src/bin/sh/exec.c Sat Aug 1 17:51:18 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: exec.c,v 1.53 2018/07/25 14:42:50 kre Exp $ */ +/* $NetBSD: exec.c,v 1.54 2020/08/01 17:51:18 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)exec.c 8.4 (Berkeley) 6/8/95"; #else -__RCSID("$NetBSD: exec.c,v 1.53 2018/07/25 14:42:50 kre Exp $"); +__RCSID("$NetBSD: exec.c,v 1.54 2020/08/01 17:51:18 kre Exp $"); #endif #endif /* not lint */ @@ -667,6 +667,10 @@ loop: cmdp = _cmd; } else cmdp = cmdlookup(name, 1); + + if (cmdp->cmdtype == CMDFUNCTION) + cmdp = _cmd; + cmdp->cmdtype = CMDNORMAL; cmdp->param.index = idx; INTON;
CVS commit: src/bin/ls
Module Name:src Committed By: christos Date: Tue Jul 7 14:29:07 UTC 2020 Modified Files: src/bin/ls: ls.c Log Message: Fix skipping of directories that begin with a '.' in -R mode. It is not enough to avoid displaying the contents of the directory, we need to set FTS_SKIP to avoid descending into any subdirs too. Otherwise, if a ".foo" directory has a subdirectory "bar", ls will descend into bar and display its contents. From Todd Miller To generate a diff of this commit: cvs rdiff -u -r1.76 -r1.77 src/bin/ls/ls.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/ls/ls.c diff -u src/bin/ls/ls.c:1.76 src/bin/ls/ls.c:1.77 --- src/bin/ls/ls.c:1.76 Mon Feb 6 16:06:04 2017 +++ src/bin/ls/ls.c Tue Jul 7 10:29:06 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: ls.c,v 1.76 2017/02/06 21:06:04 rin Exp $ */ +/* $NetBSD: ls.c,v 1.77 2020/07/07 14:29:06 christos Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 19 #if 0 static char sccsid[] = "@(#)ls.c 8.7 (Berkeley) 8/5/94"; #else -__RCSID("$NetBSD: ls.c,v 1.76 2017/02/06 21:06:04 rin Exp $"); +__RCSID("$NetBSD: ls.c,v 1.77 2020/07/07 14:29:06 christos Exp $"); #endif #endif /* not lint */ @@ -450,8 +450,10 @@ traverse(int argc, char *argv[], int opt break; case FTS_D: if (p->fts_level != FTS_ROOTLEVEL && - p->fts_name[0] == '.' && !f_listdot) + p->fts_name[0] == '.' && !f_listdot) { +(void)fts_set(ftsp, p, FTS_SKIP); break; + } /* * If already output something, put out a newline as
CVS commit: src/bin/mv
Module Name:src Committed By: riastradh Date: Wed Jun 24 17:00:58 UTC 2020 Modified Files: src/bin/mv: mv.1 Log Message: Note that -h is an extension to POSIX. Bump date. To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/bin/mv/mv.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/mv/mv.1 diff -u src/bin/mv/mv.1:1.31 src/bin/mv/mv.1:1.32 --- src/bin/mv/mv.1:1.31 Wed Jun 24 16:58:12 2020 +++ src/bin/mv/mv.1 Wed Jun 24 17:00:58 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: mv.1,v 1.31 2020/06/24 16:58:12 riastradh Exp $ +.\" $NetBSD: mv.1,v 1.32 2020/06/24 17:00:58 riastradh Exp $ .\" .\" Copyright (c) 1989, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -32,7 +32,7 @@ .\" .\" @(#)mv.1 8.1 (Berkeley) 5/31/93 .\" -.Dd August 10, 2016 +.Dd June 24, 2020 .Dt MV 1 .Os .Sh NAME @@ -146,8 +146,10 @@ utility is expected to be compatible. .Pp The +.Fl h +and .Fl v -option is an extension to +options are extensions to .St -p1003.2 . .Sh HISTORY An
CVS commit: src/bin/mv
Module Name:src Committed By: riastradh Date: Wed Jun 24 16:58:12 UTC 2020 Modified Files: src/bin/mv: mv.1 mv.c Log Message: New mv -h option. `mv -h source target' just issues rename(source, target) without discriminating on whether target resolves to a directory; this way you can atomically replace a symlink to a directory. To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/bin/mv/mv.1 cvs rdiff -u -r1.45 -r1.46 src/bin/mv/mv.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/mv/mv.1 diff -u src/bin/mv/mv.1:1.30 src/bin/mv/mv.1:1.31 --- src/bin/mv/mv.1:1.30 Tue Jul 4 06:50:04 2017 +++ src/bin/mv/mv.1 Wed Jun 24 16:58:12 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: mv.1,v 1.30 2017/07/04 06:50:04 wiz Exp $ +.\" $NetBSD: mv.1,v 1.31 2020/06/24 16:58:12 riastradh Exp $ .\" .\" Copyright (c) 1989, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -40,7 +40,7 @@ .Nd move files .Sh SYNOPSIS .Nm -.Op Fl fiv +.Op Fl fhiv .Ar source target .Nm .Op Fl fiv @@ -54,7 +54,9 @@ operand to the destination path named by .Ar target operand. This form is assumed when the last operand does not name an already -existing directory. +existing directory or when the +.Fl h +flag is specified. .Pp In its second form, .Nm @@ -72,6 +74,11 @@ The following options are available: .It Fl f Do not prompt for confirmation before overwriting the destination path. +.It Fl h +Try to rename the source to the target irrespective of whether the +target may resolve to a directory. +This option allows atomically replacing a symbolic link to a +directory. .It Fl i Causes .Nm Index: src/bin/mv/mv.c diff -u src/bin/mv/mv.c:1.45 src/bin/mv/mv.c:1.46 --- src/bin/mv/mv.c:1.45 Sun Feb 28 10:59:29 2016 +++ src/bin/mv/mv.c Wed Jun 24 16:58:12 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: mv.c,v 1.45 2016/02/28 10:59:29 mrg Exp $ */ +/* $NetBSD: mv.c,v 1.46 2020/06/24 16:58:12 riastradh Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 19 #if 0 static char sccsid[] = "@(#)mv.c 8.2 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: mv.c,v 1.45 2016/02/28 10:59:29 mrg Exp $"); +__RCSID("$NetBSD: mv.c,v 1.46 2020/06/24 16:58:12 riastradh Exp $"); #endif #endif /* not lint */ @@ -65,7 +65,7 @@ __RCSID("$NetBSD: mv.c,v 1.45 2016/02/28 #include "pathnames.h" -static int fflg, iflg, vflg; +static int fflg, hflg, iflg, vflg; static int stdin_ok; static sig_atomic_t pinfo; @@ -93,8 +93,11 @@ main(int argc, char *argv[]) setprogname(argv[0]); (void)setlocale(LC_ALL, ""); - while ((ch = getopt(argc, argv, "ifv")) != -1) + while ((ch = getopt(argc, argv, "hifv")) != -1) switch (ch) { + case 'h': + hflg = 1; + break; case 'i': fflg = 0; iflg = 1; @@ -123,7 +126,7 @@ main(int argc, char *argv[]) * If the stat on the target fails or the target isn't a directory, * try the move. More than 2 arguments is an error in this case. */ - if (stat(argv[argc - 1], ) || !S_ISDIR(sb.st_mode)) { + if (hflg || stat(argv[argc - 1], ) || !S_ISDIR(sb.st_mode)) { if (argc > 2) usage(); exit(do_move(argv[0], argv[1])); @@ -419,7 +422,7 @@ copy(char *from, char *to) static void usage(void) { - (void)fprintf(stderr, "usage: %s [-fiv] source target\n" + (void)fprintf(stderr, "usage: %s [-fhiv] source target\n" " %s [-fiv] source ... directory\n", getprogname(), getprogname()); exit(1);
CVS commit: src/bin/setfacl
Module Name:src Committed By: wiz Date: Thu Jun 18 19:44:01 UTC 2020 Modified Files: src/bin/setfacl: setfacl.c Log Message: Sync usage with manpage. To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/bin/setfacl/setfacl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/setfacl/setfacl.c diff -u src/bin/setfacl/setfacl.c:1.2 src/bin/setfacl/setfacl.c:1.3 --- src/bin/setfacl/setfacl.c:1.2 Fri May 22 01:28:44 2020 +++ src/bin/setfacl/setfacl.c Thu Jun 18 19:44:01 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: setfacl.c,v 1.2 2020/05/22 01:28:44 joerg Exp $ */ +/* $NetBSD: setfacl.c,v 1.3 2020/06/18 19:44:01 wiz Exp $ */ /*- * Copyright (c) 2001 Chris D. Faulhaber @@ -30,7 +30,7 @@ #if 0 __FBSDID("$FreeBSD: head/bin/setfacl/setfacl.c 339793 2018-10-26 21:17:06Z markj $"); #else -__RCSID("$NetBSD: setfacl.c,v 1.2 2020/05/22 01:28:44 joerg Exp $"); +__RCSID("$NetBSD: setfacl.c,v 1.3 2020/06/18 19:44:01 wiz Exp $"); #endif #include @@ -85,9 +85,9 @@ static void usage(void) { - fprintf(stderr, "usage: setfacl [-R [-H | -L | -P]] [-bdhkn] " - "[-a position entries] [-m entries] [-M file] " - "[-x entries] [-X file] [file ...]\n"); + fprintf(stderr, "usage: setfacl [-bdhkn] " + "[-a position entries] [-M file] [-m entries] " + "[-R [-H | -L | -P]] [-X file] [-x entries | position] [file ...]\n"); exit(1); }
CVS commit: src/bin/setfacl
Module Name:src Committed By: wiz Date: Thu Jun 18 19:43:53 UTC 2020 Modified Files: src/bin/setfacl: setfacl.1 Log Message: Sort option descriptions. Sort options in SYNOPSIS. Fix xrefs. Comment out acl(9) which we don't have. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/bin/setfacl/setfacl.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/setfacl/setfacl.1 diff -u src/bin/setfacl/setfacl.1:1.1 src/bin/setfacl/setfacl.1:1.2 --- src/bin/setfacl/setfacl.1:1.1 Sat May 16 18:31:45 2020 +++ src/bin/setfacl/setfacl.1 Thu Jun 18 19:43:53 2020 @@ -1,3 +1,4 @@ +.\" $NetBSD: setfacl.1,v 1.2 2020/06/18 19:43:53 wiz Exp $ .\"- .\" Copyright (c) 2001 Chris D. Faulhaber .\" Copyright (c) 2011 Edward Tomasz Napierała @@ -34,13 +35,13 @@ .Nd set ACL information .Sh SYNOPSIS .Nm -.Op Fl R Op Fl H | L | P .Op Fl bdhkn .Op Fl a Ar position entries -.Op Fl m Ar entries .Op Fl M Ar file -.Op Fl x Ar entries | position +.Op Fl m Ar entries +.Op Fl R Op Fl H | L | P .Op Fl X Ar file +.Op Fl x Ar entries | position .Op Ar .Sh DESCRIPTION The @@ -82,28 +83,36 @@ access ACL entries. Currently only directories may have default ACL's. This option is not applicable to NFSv4 ACLs. -.It Fl h -If the target of the operation is a symbolic link, perform the operation -on the symbolic link itself, rather than following the link. .It Fl H If the .Fl R option is specified, symbolic links on the command line are followed and hence unaffected by the command. (Symbolic links encountered during tree traversal are not followed.) +.It Fl h +If the target of the operation is a symbolic link, perform the operation +on the symbolic link itself, rather than following the link. .It Fl k Delete any default ACL entries on the specified files. -It -is not considered an error if the specified files do not have +It is not considered an error if the specified files do not have any default ACL entries. -An error will be reported if any of -the specified files cannot have a default entry (i.e., -non-directories). +An error will be reported if any of the specified files cannot have +a default entry (i.e., non-directories). This option is not applicable to NFSv4 ACLs. .It Fl L If the .Fl R option is specified, all symbolic links are followed. +.It Fl M Ar file +Modify the ACL entries on the specified files by adding new +ACL entries and modifying existing ACL entries with the ACL +entries specified in the file +.Ar file . +If +.Ar file +is +.Fl , +the input is taken from stdin. .It Fl m Ar entries Modify the ACL on the specified file. New entries will be added, and existing entries will be modified @@ -115,19 +124,8 @@ For NFSv4 ACLs, it is recommended to use and .Fl x options instead. -.It Fl M Ar file -Modify the ACL entries on the specified files by adding new -ACL entries and modifying existing ACL entries with the ACL -entries specified in the file -.Ar file . -If -.Ar file -is -.Fl , -the input is taken from stdin. .It Fl n -Do not recalculate the permissions associated with the ACL -mask entry. +Do not recalculate the permissions associated with the ACL mask entry. This option is not applicable to NFSv4 ACLs. .It Fl P If the @@ -138,6 +136,10 @@ This is the default. Perform the action recursively on any specified directories. When modifying or adding NFSv4 ACL entries, inheritance flags are applied only to directories. +.It Fl X Ar file +Remove the ACL entries specified in the file +.Ar file +from the access or default ACL of the specified files. .It Fl x Ar entries | position If .Ar entries @@ -146,10 +148,6 @@ from the access or default ACL of the sp Otherwise, remove entry at index .Ar position , counting from zero. -.It Fl X Ar file -Remove the ACL entries specified in the file -.Ar file -from the access or default ACL of the specified files. .El .Pp The above options are evaluated in the order specified @@ -190,8 +188,8 @@ ACL entry. .It Ar "ACL qualifier" The ACL qualifier field describes the user or group associated with the ACL entry. -It may consist of one of the following: uid or -user name, gid or group name, or empty. +It may consist of one of the following: UID or +user name, GID or group name, or empty. For .Dq Li user ACL entries, an empty field specifies access granted to the @@ -324,8 +322,8 @@ literally, everyone, including file owne .It Ar "ACL qualifier" The ACL qualifier field describes the user or group associated with the ACL entry. -It may consist of one of the following: uid or -user name, or gid or group name. +It may consist of one of the following: UID or +user name, or GID or group name. In entries whose tag type is one of .Dq Li owner@ , .Dq Li group@ , @@ -487,11 +485,11 @@ Copy ACL entries from to .Pa file2 . .Sh SEE ALSO +.Xr getextattr 1 , .Xr getfacl 1 , +.Xr setextattr 1 , .Xr acl 3 , -.Xr getextattr 8 , -.Xr
CVS commit: src/bin/getfacl
Module Name:src Committed By: wiz Date: Thu Jun 18 19:36:13 UTC 2020 Modified Files: src/bin/getfacl: getfacl.1 Log Message: Fix xrefs, comment out acl(9) which we don't have. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/bin/getfacl/getfacl.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/getfacl/getfacl.1 diff -u src/bin/getfacl/getfacl.1:1.1 src/bin/getfacl/getfacl.1:1.2 --- src/bin/getfacl/getfacl.1:1.1 Sat May 16 18:31:45 2020 +++ src/bin/getfacl/getfacl.1 Thu Jun 18 19:36:13 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: getfacl.1,v 1.1 2020/05/16 18:31:45 christos Exp $ +.\" $NetBSD: getfacl.1,v 1.2 2020/06/18 19:36:13 wiz Exp $ .\"- .\" Copyright (c) 2000, 2001, 2002 Robert N. M. Watson .\" All rights reserved. @@ -116,11 +116,11 @@ Retrieve the default ACL for the directo .Pa / , if any. .Sh SEE ALSO +.Xr getextattr 1 , +.Xr setextattr 1 , .Xr setfacl 1 , .Xr acl 3 , -.Xr getextattr 8 , -.Xr setextattr 8 , -.Xr acl 9 , +.\".Xr acl 9 , .Xr extattr 9 .Sh STANDARDS The
CVS commit: src/bin/expr
Module Name:src Committed By: kamil Date: Thu Jun 11 13:08:08 UTC 2020 Modified Files: src/bin/expr: expr.y Log Message: Fix typo To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/bin/expr/expr.y Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/expr/expr.y diff -u src/bin/expr/expr.y:1.45 src/bin/expr/expr.y:1.46 --- src/bin/expr/expr.y:1.45 Wed Jun 27 17:23:36 2018 +++ src/bin/expr/expr.y Thu Jun 11 13:08:07 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: expr.y,v 1.45 2018/06/27 17:23:36 kamil Exp $ */ +/* $NetBSD: expr.y,v 1.46 2020/06/11 13:08:07 kamil Exp $ */ /*_ * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ %{ #include #ifndef lint -__RCSID("$NetBSD: expr.y,v 1.45 2018/06/27 17:23:36 kamil Exp $"); +__RCSID("$NetBSD: expr.y,v 1.46 2020/06/11 13:08:07 kamil Exp $"); #endif /* not lint */ #include @@ -361,7 +361,7 @@ perform_arith_op(const char *left, const r = -r; } - /* - remove the case of legative l and positive r */ + /* - remove the case of negative l and positive r */ if (l < 0 && r >= 0) { /* Use res as a temporary variable */ res = l;
CVS commit: src/bin/cp
Module Name:src Committed By: christos Date: Fri May 22 14:54:30 UTC 2020 Modified Files: src/bin/cp: cp.c Log Message: fix reversed test. To generate a diff of this commit: cvs rdiff -u -r1.61 -r1.62 src/bin/cp/cp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/cp/cp.c diff -u src/bin/cp/cp.c:1.61 src/bin/cp/cp.c:1.62 --- src/bin/cp/cp.c:1.61 Sun May 17 19:34:11 2020 +++ src/bin/cp/cp.c Fri May 22 10:54:30 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cp.c,v 1.61 2020/05/17 23:34:11 christos Exp $ */ +/* $NetBSD: cp.c,v 1.62 2020/05/22 14:54:30 christos Exp $ */ /* * Copyright (c) 1988, 1993, 1994 @@ -43,7 +43,7 @@ __COPYRIGHT( #if 0 static char sccsid[] = "@(#)cp.c 8.5 (Berkeley) 4/29/95"; #else -__RCSID("$NetBSD: cp.c,v 1.61 2020/05/17 23:34:11 christos Exp $"); +__RCSID("$NetBSD: cp.c,v 1.62 2020/05/22 14:54:30 christos Exp $"); #endif #endif /* not lint */ @@ -517,7 +517,7 @@ copy(char *argv[], enum op type, int fts this_failed = any_failed = 1; #endif } -if (this_failed && (dne = popdne())) +if (!this_failed && (dne = popdne())) (void)chmod(to.p_path, curr->fts_statp->st_mode); }
CVS commit: src/bin/setfacl
Module Name:src Committed By: joerg Date: Fri May 22 01:28:45 UTC 2020 Modified Files: src/bin/setfacl: setfacl.c Log Message: Mark usage as dead To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/bin/setfacl/setfacl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/setfacl/setfacl.c diff -u src/bin/setfacl/setfacl.c:1.1 src/bin/setfacl/setfacl.c:1.2 --- src/bin/setfacl/setfacl.c:1.1 Sat May 16 18:31:45 2020 +++ src/bin/setfacl/setfacl.c Fri May 22 01:28:44 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: setfacl.c,v 1.1 2020/05/16 18:31:45 christos Exp $ */ +/* $NetBSD: setfacl.c,v 1.2 2020/05/22 01:28:44 joerg Exp $ */ /*- * Copyright (c) 2001 Chris D. Faulhaber @@ -30,7 +30,7 @@ #if 0 __FBSDID("$FreeBSD: head/bin/setfacl/setfacl.c 339793 2018-10-26 21:17:06Z markj $"); #else -__RCSID("$NetBSD: setfacl.c,v 1.1 2020/05/16 18:31:45 christos Exp $"); +__RCSID("$NetBSD: setfacl.c,v 1.2 2020/05/22 01:28:44 joerg Exp $"); #endif #include @@ -79,7 +79,7 @@ static acl_type_t acl_type = ACL_TYPE_AC static int handle_file(FTS *ftsp, FTSENT *file); static acl_t clear_inheritance_flags(acl_t acl); static char **stdin_files(void); -static void usage(void); +static __dead void usage(void); static void usage(void)
CVS commit: src/bin/getfacl
Module Name:src Committed By: joerg Date: Fri May 22 01:28:00 UTC 2020 Modified Files: src/bin/getfacl: getfacl.c Log Message: Don't return from dead functions. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/bin/getfacl/getfacl.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/getfacl/getfacl.c diff -u src/bin/getfacl/getfacl.c:1.1 src/bin/getfacl/getfacl.c:1.2 --- src/bin/getfacl/getfacl.c:1.1 Sat May 16 18:31:45 2020 +++ src/bin/getfacl/getfacl.c Fri May 22 01:28:00 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: getfacl.c,v 1.1 2020/05/16 18:31:45 christos Exp $ */ +/* $NetBSD: getfacl.c,v 1.2 2020/05/22 01:28:00 joerg Exp $ */ /*- * Copyright (c) 1999, 2001, 2002 Robert N M Watson @@ -37,7 +37,7 @@ #if 0 __FBSDID("$FreeBSD: head/bin/getfacl/getfacl.c 340014 2018-11-01 17:45:29Z markj $"); #else -__RCSID("$NetBSD: getfacl.c,v 1.1 2020/05/16 18:31:45 christos Exp $"); +__RCSID("$NetBSD: getfacl.c,v 1.2 2020/05/22 01:28:00 joerg Exp $"); #endif #include @@ -61,6 +61,7 @@ usage(void) { fprintf(stderr, "Usage: %s [-dhnqv] [file ...]\n", getprogname()); + exit(1); } static char * @@ -319,7 +320,6 @@ main(int argc, char *argv[]) break; default: usage(); - return(-1); } argc -= optind; argv += optind;
CVS commit: src/bin
Module Name:src Committed By: christos Date: Sun May 17 23:34:11 UTC 2020 Modified Files: src/bin/cp: Makefile cp.c utils.c src/bin/ls: Makefile print.c Log Message: No ACL support for install media (SMALLPROG) To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/bin/cp/Makefile cvs rdiff -u -r1.60 -r1.61 src/bin/cp/cp.c cvs rdiff -u -r1.48 -r1.49 src/bin/cp/utils.c cvs rdiff -u -r1.14 -r1.15 src/bin/ls/Makefile cvs rdiff -u -r1.56 -r1.57 src/bin/ls/print.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/cp/Makefile diff -u src/bin/cp/Makefile:1.9 src/bin/cp/Makefile:1.10 --- src/bin/cp/Makefile:1.9 Sun Jul 20 18:36:37 1997 +++ src/bin/cp/Makefile Sun May 17 19:34:11 2020 @@ -1,7 +1,11 @@ -# $NetBSD: Makefile,v 1.9 1997/07/20 22:36:37 christos Exp $ +# $NetBSD: Makefile,v 1.10 2020/05/17 23:34:11 christos Exp $ # @(#)Makefile 8.1 (Berkeley) 5/31/93 PROG= cp SRCS= cp.c utils.c +.ifdef SMALLPROG +CPPFLAGS+=-DSMALL +.endif + .include Index: src/bin/cp/cp.c diff -u src/bin/cp/cp.c:1.60 src/bin/cp/cp.c:1.61 --- src/bin/cp/cp.c:1.60 Sat May 16 14:31:45 2020 +++ src/bin/cp/cp.c Sun May 17 19:34:11 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: cp.c,v 1.60 2020/05/16 18:31:45 christos Exp $ */ +/* $NetBSD: cp.c,v 1.61 2020/05/17 23:34:11 christos Exp $ */ /* * Copyright (c) 1988, 1993, 1994 @@ -43,7 +43,7 @@ __COPYRIGHT( #if 0 static char sccsid[] = "@(#)cp.c 8.5 (Berkeley) 4/29/95"; #else -__RCSID("$NetBSD: cp.c,v 1.60 2020/05/16 18:31:45 christos Exp $"); +__RCSID("$NetBSD: cp.c,v 1.61 2020/05/17 23:34:11 christos Exp $"); #endif #endif /* not lint */ @@ -511,9 +511,11 @@ copy(char *argv[], enum op type, int fts if (pflag) { if (setfile(curr->fts_statp, 0)) this_failed = any_failed = 1; +#ifndef SMALL if (preserve_dir_acls(curr->fts_statp, curr->fts_accpath, to.p_path) != 0) this_failed = any_failed = 1; +#endif } if (this_failed && (dne = popdne())) (void)chmod(to.p_path, Index: src/bin/cp/utils.c diff -u src/bin/cp/utils.c:1.48 src/bin/cp/utils.c:1.49 --- src/bin/cp/utils.c:1.48 Sat May 16 14:31:45 2020 +++ src/bin/cp/utils.c Sun May 17 19:34:11 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: utils.c,v 1.48 2020/05/16 18:31:45 christos Exp $ */ +/* $NetBSD: utils.c,v 1.49 2020/05/17 23:34:11 christos Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)utils.c 8.3 (Berkeley) 4/1/94"; #else -__RCSID("$NetBSD: utils.c,v 1.48 2020/05/16 18:31:45 christos Exp $"); +__RCSID("$NetBSD: utils.c,v 1.49 2020/05/17 23:34:11 christos Exp $"); #endif #endif /* not lint */ @@ -43,7 +43,9 @@ __RCSID("$NetBSD: utils.c,v 1.48 2020/05 #include #include #include +#ifndef SMALL #include +#endif #include #include @@ -256,8 +258,10 @@ copy_file(FTSENT *entp, int dne) if (pflag && (fcpxattr(from_fd, to_fd) != 0)) warn("%s: error copying extended attributes", to.p_path); +#ifndef SMALL if (pflag && preserve_fd_acls(from_fd, to_fd) != 0) rval = 1; +#endif (void)close(from_fd); @@ -408,6 +412,7 @@ setfile(struct stat *fs, int fd) return (rval); } +#ifndef SMALL int preserve_fd_acls(int source_fd, int dest_fd) { @@ -546,6 +551,7 @@ preserve_dir_acls(struct stat *fs, char acl_free(acl); return (0); } +#endif void usage(void) Index: src/bin/ls/Makefile diff -u src/bin/ls/Makefile:1.14 src/bin/ls/Makefile:1.15 --- src/bin/ls/Makefile:1.14 Thu Dec 14 15:09:36 2006 +++ src/bin/ls/Makefile Sun May 17 19:34:11 2020 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.14 2006/12/14 20:09:36 he Exp $ +# $NetBSD: Makefile,v 1.15 2020/05/17 23:34:11 christos Exp $ # @(#)Makefile 8.1 (Berkeley) 6/2/93 PROG= ls @@ -7,4 +7,8 @@ SRCS= cmp.c ls.c main.c print.c util.c LDADD+= -lutil DPADD+= ${LIBUTIL} +.ifdef SMALLPROG +CPPFLAGS+= -DSMALL +.endif + .include Index: src/bin/ls/print.c diff -u src/bin/ls/print.c:1.56 src/bin/ls/print.c:1.57 --- src/bin/ls/print.c:1.56 Sat May 16 14:31:45 2020 +++ src/bin/ls/print.c Sun May 17 19:34:11 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: print.c,v 1.56 2020/05/16 18:31:45 christos Exp $ */ +/* $NetBSD: print.c,v 1.57 2020/05/17 23:34:11 christos Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -37,13 +37,15 @@ #if 0 static char sccsid[] = "@(#)print.c 8.5 (Berkeley) 7/28/94"; #else -__RCSID("$NetBSD: print.c,v 1.56 2020/05/16 18:31:45 christos Exp $"); +__RCSID("$NetBSD: print.c,v 1.57 2020/05/17 23:34:11 christos Exp $"); #endif #endif /* not lint */ #include #include +#ifndef SMALL #include +#endif #include #include @@ -69,7 +71,9 @@ static void printlink(FTSENT *); static void printtime(time_t); static void printtotal(DISPLAY *dp); static int printtype(u_int); +#ifndef SMALL static void aclmode(char *, const FTSENT *); +#endif static time_t now; @@ -156,7 +160,9 @@ printlong(DISPLAY *dp)
CVS commit: src/bin/rcp
Module Name:src Committed By: aymeric Date: Wed May 6 18:15:40 UTC 2020 Modified Files: src/bin/rcp: rcp.c Log Message: In sink(), upon error, avoid multiple replies to the source as this would lead to a desynchronization of the protocol and further files or directories to be ignored or corrupted. Reported by Daniel Goujot, Georges-Axel Jaloyan, Ryan Lahfa, and David Naccache. To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/bin/rcp/rcp.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/rcp/rcp.c diff -u src/bin/rcp/rcp.c:1.49 src/bin/rcp/rcp.c:1.50 --- src/bin/rcp/rcp.c:1.49 Mon May 7 15:22:54 2012 +++ src/bin/rcp/rcp.c Wed May 6 18:15:40 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: rcp.c,v 1.49 2012/05/07 15:22:54 chs Exp $ */ +/* $NetBSD: rcp.c,v 1.50 2020/05/06 18:15:40 aymeric Exp $ */ /* * Copyright (c) 1983, 1990, 1992, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19 #if 0 static char sccsid[] = "@(#)rcp.c 8.2 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: rcp.c,v 1.49 2012/05/07 15:22:54 chs Exp $"); +__RCSID("$NetBSD: rcp.c,v 1.50 2020/05/06 18:15:40 aymeric Exp $"); #endif #endif /* not lint */ @@ -470,7 +470,6 @@ sink(int argc, char *argv[]) static BUF buffer; struct stat stb; struct timeval tv[2]; - enum { YES, NO, DISPLAYED } wrerr; BUF *bp; ssize_t j; off_t i; @@ -480,8 +479,9 @@ sink(int argc, char *argv[]) mode_t mask; mode_t mode; mode_t omode; - int setimes, targisdir; + int setimes, targisdir, wrerr; int wrerrno = 0; /* pacify gcc */ + const char *wrcontext = NULL; char ch, *cp, *np, *targ, *vect[1], buf[BUFSIZ]; const char *why; off_t size; @@ -624,9 +624,7 @@ sink(int argc, char *argv[]) sink(1, vect); if (setimes) { setimes = 0; -if (utimes(np, tv) < 0) -run_err("%s: set times: %s", - np, strerror(errno)); +(void) utimes(np, tv); } if (mod_flag) (void)chmod(np, mode); @@ -644,7 +642,20 @@ bad: run_err("%s: %s", np, strerror(er continue; } cp = bp->buf; - wrerr = NO; + wrerr = 0; + +/* + * Like run_err(), but don't send any message to the remote end. + * Instead, record the first error and send that in the end. + */ +#define RUN_ERR(w_context) do { \ + if (!wrerr) { \ + wrerrno = errno; \ + wrcontext = w_context; \ + wrerr = 1; \ + }\ +} while(0) + count = 0; for (i = 0; i < size; i += BUFSIZ) { amt = BUFSIZ; @@ -663,69 +674,56 @@ bad: run_err("%s: %s", np, strerror(er } while (amt > 0); if (count == bp->cnt) { /* Keep reading so we stay sync'd up. */ -if (wrerr == NO) { +if (!wrerr) { j = write(ofd, bp->buf, (size_t)count); if (j != count) { - wrerr = YES; - wrerrno = j >= 0 ? EIO : errno; + if (j >= 0) + errno = EIO; + RUN_ERR("write"); } } count = 0; cp = bp->buf; } } - if (count != 0 && wrerr == NO && + if (count != 0 && !wrerr && (j = write(ofd, bp->buf, (size_t)count)) != count) { - wrerr = YES; - wrerrno = j >= 0 ? EIO : errno; - } - if (ftruncate(ofd, size)) { - run_err("%s: truncate: %s", np, strerror(errno)); - wrerr = DISPLAYED; + if (j >= 0) +errno = EIO; + RUN_ERR("write"); } + if (ftruncate(ofd, size)) + RUN_ERR("truncate"); + if (pflag) { if (exists || omode != mode) if (fchmod(ofd, omode)) - run_err("%s: set mode: %s", - np, strerror(errno)); + RUN_ERR("set mode"); } else { if (!exists && omode != mode) if (fchmod(ofd, omode & ~mask)) - run_err("%s: set mode: %s", - np, strerror(errno)); + RUN_ERR("set mode"); } #ifndef __SVR4 - if (setimes && wrerr == NO) { + if (setimes && !wrerr) { setimes = 0; - if (futimes(ofd, tv) < 0) { -run_err("%s: set times: %s", -np, strerror(errno)); -wrerr = DISPLAYED; - } + if (futimes(ofd, tv) < 0) +RUN_ERR("set times"); } #endif (void)close(ofd); #ifdef __SVR4 - if (setimes && wrerr == NO) { + if (setimes && !wrerr) { setimes = 0; - if (utimes(np, tv) < 0) { -run_err("%s: set times: %s", -np, strerror(errno)); -wrerr = DISPLAYED; - } + if (utimes(np, tv) < 0) +RUN_ERR("set times"); } #endif (void)response(); - switch(wrerr) { - case YES: - run_err("%s: write: %s", np, strerror(wrerrno)); - break; - case NO: + if (wrerr) + run_err("%s: %s: %s", np, wrcontext, strerror(wrerrno)); + else (void)write(rem, "", 1); - break; - case DISPLAYED: - break; - } } out:
CVS commit: src/bin/kill
Module Name:src Committed By: kre Date: Wed May 6 13:13:50 UTC 2020 Modified Files: src/bin/kill: kill.1 Log Message: Bump date for previous change... I frequently forget that bit. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/bin/kill/kill.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/kill/kill.1 diff -u src/bin/kill/kill.1:1.29 src/bin/kill/kill.1:1.30 --- src/bin/kill/kill.1:1.29 Wed May 6 09:07:15 2020 +++ src/bin/kill/kill.1 Wed May 6 13:13:50 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: kill.1,v 1.29 2020/05/06 09:07:15 kre Exp $ +.\" $NetBSD: kill.1,v 1.30 2020/05/06 13:13:50 kre Exp $ .\" .\" Copyright (c) 1980, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -32,7 +32,7 @@ .\" .\" @(#)kill.1 8.2 (Berkeley) 4/28/95 .\" -.Dd April 22, 2017 +.Dd May 6, 2020 .Dt KILL 1 .Os .Sh NAME
CVS commit: src/bin/kill
Module Name:src Committed By: kre Date: Wed May 6 09:07:15 UTC 2020 Modified Files: src/bin/kill: kill.1 Log Message: kill is built-in to more than just csh(1). While here, add missing Xr sh 1 (which was previously needed, moreso now) and also include STOP and CONT in the list of common signals. To generate a diff of this commit: cvs rdiff -u -r1.28 -r1.29 src/bin/kill/kill.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/kill/kill.1 diff -u src/bin/kill/kill.1:1.28 src/bin/kill/kill.1:1.29 --- src/bin/kill/kill.1:1.28 Sat Apr 22 23:01:36 2017 +++ src/bin/kill/kill.1 Wed May 6 09:07:15 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: kill.1,v 1.28 2017/04/22 23:01:36 christos Exp $ +.\" $NetBSD: kill.1,v 1.29 2020/05/06 09:07:15 kre Exp $ .\" .\" Copyright (c) 1980, 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -120,10 +120,19 @@ KILL (non-catchable, non-ignorable kill) ALRM (alarm clock) .It 15 TERM (software termination signal) +.It 17 +STOP (non-catchable, non-ignorable, causes process to temporarily stop, +after which it can later be resumed using +.Dv SIGCONT ) +.It 19 +CONT (stopped proceses resume execution) .El .Pp .Nm -is a built-in to +is a built-in to most shells, +including +.Xr sh 1 +and .Xr csh 1 ; it allows job specifiers of the form ``%...'' as arguments so process id's are not as often used as @@ -131,6 +140,8 @@ so process id's are not as often used as arguments. See .Xr csh 1 +or +.Xr sh 1 for details. .Sh DIAGNOSTICS .Ex -std @@ -139,6 +150,7 @@ for details. .Xr pgrep 1 , .Xr pkill 1 , .Xr ps 1 , +.Xr sh 1 , .Xr kill 2 , .Xr sigaction 2 , .Xr signal 7
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Thu Apr 23 09:01:33 UTC 2020 Modified Files: src/bin/sh: eval.c Log Message: Stop forcing the -e option off in the subshell createds for a command substitution. This was inherited in the big "-e" fixup patch set (rev 1.50) of Jan 2000, which came from dash. dash no longer acts this way. To generate a diff of this commit: cvs rdiff -u -r1.178 -r1.179 src/bin/sh/eval.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/eval.c diff -u src/bin/sh/eval.c:1.178 src/bin/sh/eval.c:1.179 --- src/bin/sh/eval.c:1.178 Tue Feb 4 16:06:59 2020 +++ src/bin/sh/eval.c Thu Apr 23 09:01:33 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: eval.c,v 1.178 2020/02/04 16:06:59 kre Exp $ */ +/* $NetBSD: eval.c,v 1.179 2020/04/23 09:01:33 kre Exp $ */ /*- * Copyright (c) 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95"; #else -__RCSID("$NetBSD: eval.c,v 1.178 2020/02/04 16:06:59 kre Exp $"); +__RCSID("$NetBSD: eval.c,v 1.179 2020/04/23 09:01:33 kre Exp $"); #endif #endif /* not lint */ @@ -771,7 +771,6 @@ evalbackcmd(union node *n, struct backcm FORCEINTON; close(pip[0]); movefd(pip[1], 1); - eflag = 0; evaltree(n, EV_EXIT); /* NOTREACHED */ }
CVS commit: src/bin/csh
Module Name:src Committed By: joerg Date: Fri Apr 3 18:11:29 UTC 2020 Modified Files: src/bin/csh: csh.c csh.h dir.c dir.h proc.c proc.h Log Message: Don't depend on common declarations. To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/bin/csh/csh.c cvs rdiff -u -r1.28 -r1.29 src/bin/csh/csh.h cvs rdiff -u -r1.32 -r1.33 src/bin/csh/dir.c cvs rdiff -u -r1.8 -r1.9 src/bin/csh/dir.h cvs rdiff -u -r1.38 -r1.39 src/bin/csh/proc.c cvs rdiff -u -r1.14 -r1.15 src/bin/csh/proc.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/csh/csh.c diff -u src/bin/csh/csh.c:1.49 src/bin/csh/csh.c:1.50 --- src/bin/csh/csh.c:1.49 Sun Jan 12 18:36:55 2020 +++ src/bin/csh/csh.c Fri Apr 3 18:11:29 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: csh.c,v 1.49 2020/01/12 18:36:55 christos Exp $ */ +/* $NetBSD: csh.c,v 1.50 2020/04/03 18:11:29 joerg Exp $ */ /*- * Copyright (c) 1980, 1991, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = "@(#)csh.c 8.2 (Berkeley) 10/12/93"; #else -__RCSID("$NetBSD: csh.c,v 1.49 2020/01/12 18:36:55 christos Exp $"); +__RCSID("$NetBSD: csh.c,v 1.50 2020/04/03 18:11:29 joerg Exp $"); #endif #endif /* not lint */ @@ -77,6 +77,97 @@ __RCSID("$NetBSD: csh.c,v 1.49 2020/01/1 * June, 1991 */ +FILE *cshin, *cshout, *csherr; +struct timespec time0; +struct rusage ru0; +struct varent shvhed, aliases; +Char HISTSUB; +int editing; + +int child; +int chkstop; +int didfds; +int doneinp; +int exiterr; +int haderr; +int havhash; +int intact; +int intty; +int justpr; +int loginsh; +int neednote; +int noexec; +int pjobs; +int setintr; +int timflg; + +Char *arginp; +Char *ffile; +int onelflg; +Char *shtemp; + +time_t chktim; +Char *doldol; +pid_t backpid; +gid_t egid, gid; +uid_t euid, uid; +int shpgrp; +int tpgrp; + +int opgrp; + +int SHIN; +int SHOUT; +int SHERR; +int OLDSTD; + +jmp_buf reslab; + +Char *gointr; + +sig_t parintr; +sig_t parterm; + +struct Bin B; + +struct Ain lineloc; +int cantell; +Char *lap; +struct whyle *whyles; + +struct wordent *alhistp,*alhistt; + +int AsciiOnly; +int gflag; +long pnleft; +Char *pargs; +Char *pargcp; +struct Hist Histlist; +struct wordent paraml; +int eventno; +int lastev; +Char HIST; +Char HISTSUB; +const char *bname; +Char *Vsav; +Char *Vdp; +Char *Vexpath; +char **Vt; +Char **evalvec; +Char *evalp; +Char *word_chars; +Char *STR_SHELLPATH; +#ifdef _PATH_BSHELL +Char *STR_BSHELL; +#endif +Char *STR_WORD_CHARS; +Char **STR_environ; +#ifdef EDIT +EditLine *el; +History *hi; +#endif +int editing; + Char *dumphist[] = {STRhistory, STRmh, 0, 0}; Char *tildehist[] = {STRsource, STRmh, STRtildothist, 0}; Index: src/bin/csh/csh.h diff -u src/bin/csh/csh.h:1.28 src/bin/csh/csh.h:1.29 --- src/bin/csh/csh.h:1.28 Sat Jan 5 16:54:00 2019 +++ src/bin/csh/csh.h Fri Apr 3 18:11:29 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: csh.h,v 1.28 2019/01/05 16:54:00 christos Exp $ */ +/* $NetBSD: csh.h,v 1.29 2020/04/03 18:11:29 joerg Exp $ */ /*- * Copyright (c) 1980, 1991, 1993 @@ -89,7 +89,7 @@ typedef void *ioctl_t; /* Third arg of #define xcalloc(n, s) Calloc(n, s) #include -FILE *cshin, *cshout, *csherr; +extern FILE *cshin, *cshout, *csherr; #define isdir(d) (S_ISDIR(d.st_mode)) @@ -103,22 +103,22 @@ FILE *cshin, *cshout, *csherr; /* * Global flags */ -int child; /* Child shell ... errors cause exit */ -int chkstop; /* Warned of stopped jobs... allow exit */ -int didfds; /* Have setup i/o fd's for child */ -int doneinp; /* EOF indicator after reset from readc */ -int exiterr; /* Exit if error or non-zero exit status */ -int haderr; /* Reset was because of an error */ -int havhash; /* path hashing is available */ -int intact; /* We are interactive... therefore prompt */ -int intty; /* Input is a tty */ -int justpr; /* Just print because of :p hist mod */ -int loginsh; /* We are a loginsh -> .login/.logout */ -int neednote; /* Need to pnotify() */ -int noexec; /* Don't execute, just syntax check */ -int pjobs; /* want to print jobs if interrupted */ -int setintr; /* Set interrupts on/off -> Wait intr... */ -int timflg; /* Time the next waited for command */ +extern int child; /* Child shell ... errors cause exit */ +extern int chkstop; /* Warned of stopped jobs... allow exit */ +extern int didfds; /* Have setup i/o fd's for child */ +extern int doneinp; /* EOF indicator after reset from readc */ +extern int exiterr; /* Exit if error or non-zero exit status */ +extern int haderr; /* Reset was because of an error */ +extern int havhash; /* path hashing is available */ +extern int intact; /* We are interactive... therefore prompt */ +extern int intty; /* Input is a tty */ +extern int justpr; /* Just print because of :p hist mod */ +extern int loginsh; /* We are a loginsh -> .login/.logout */ +extern int neednote; /* Need to pnotify() */ +extern int
CVS commit: src/bin/sh
Module Name:src Committed By: joerg Date: Fri Apr 3 16:22:23 UTC 2020 Modified Files: src/bin/sh: redir.h Log Message: Don't define max_user_fd in the header. To generate a diff of this commit: cvs rdiff -u -r1.24 -r1.25 src/bin/sh/redir.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/redir.h diff -u src/bin/sh/redir.h:1.24 src/bin/sh/redir.h:1.25 --- src/bin/sh/redir.h:1.24 Fri Jun 30 23:01:21 2017 +++ src/bin/sh/redir.h Fri Apr 3 16:22:23 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: redir.h,v 1.24 2017/06/30 23:01:21 kre Exp $ */ +/* $NetBSD: redir.h,v 1.25 2020/04/03 16:22:23 joerg Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -52,4 +52,4 @@ void sh_close(int); struct output; int outredir(struct output *, union node *, int); -int max_user_fd; /* highest fd used by user */ +extern int max_user_fd; /* highest fd used by user */
CVS commit: src/bin/pax
Module Name:src Committed By: joerg Date: Fri Apr 3 16:13:32 UTC 2020 Modified Files: src/bin/pax: extern.h options.c Log Message: Move definition of chdname and do_chroot to options.c To generate a diff of this commit: cvs rdiff -u -r1.59 -r1.60 src/bin/pax/extern.h cvs rdiff -u -r1.118 -r1.119 src/bin/pax/options.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/pax/extern.h diff -u src/bin/pax/extern.h:1.59 src/bin/pax/extern.h:1.60 --- src/bin/pax/extern.h:1.59 Thu Aug 9 08:09:21 2012 +++ src/bin/pax/extern.h Fri Apr 3 16:13:32 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: extern.h,v 1.59 2012/08/09 08:09:21 christos Exp $ */ +/* $NetBSD: extern.h,v 1.60 2020/04/03 16:13:32 joerg Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -204,9 +204,8 @@ void options(int, char **); OPLIST * opt_next(void); int bad_opt(void); int mkpath(char *); -char *chdname; #if !HAVE_NBTOOL_CONFIG_H -int do_chroot; +extern int do_chroot; #endif /* Index: src/bin/pax/options.c diff -u src/bin/pax/options.c:1.118 src/bin/pax/options.c:1.119 --- src/bin/pax/options.c:1.118 Sat Dec 19 18:45:52 2015 +++ src/bin/pax/options.c Fri Apr 3 16:13:32 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: options.c,v 1.118 2015/12/19 18:45:52 christos Exp $ */ +/* $NetBSD: options.c,v 1.119 2020/04/03 16:13:32 joerg Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)options.c 8.2 (Berkeley) 4/18/94"; #else -__RCSID("$NetBSD: options.c,v 1.118 2015/12/19 18:45:52 christos Exp $"); +__RCSID("$NetBSD: options.c,v 1.119 2020/04/03 16:13:32 joerg Exp $"); #endif #endif /* not lint */ @@ -74,6 +74,11 @@ __RCSID("$NetBSD: options.c,v 1.118 2015 #include "mtree.h" #endif /* SMALL */ +char *chdname; +#if !HAVE_NBTOOL_CONFIG_H +int do_chroot; +#endif + /* * Routines which handle command line options */
CVS commit: src/bin/echo
Module Name:src Committed By: wiz Date: Wed Feb 26 07:14:47 UTC 2020 Modified Files: src/bin/echo: echo.1 Log Message: Add some commas. To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/bin/echo/echo.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/echo/echo.1 diff -u src/bin/echo/echo.1:1.18 src/bin/echo/echo.1:1.19 --- src/bin/echo/echo.1:1.18 Wed Feb 26 02:09:46 2020 +++ src/bin/echo/echo.1 Wed Feb 26 07:14:47 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: echo.1,v 1.18 2020/02/26 02:09:46 gutteridge Exp $ +.\" $NetBSD: echo.1,v 1.19 2020/02/26 07:14:47 wiz Exp $ .\" .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -66,8 +66,8 @@ and backslashes. .Sh EXIT STATUS .Ex -std echo .Sh SEE ALSO -.Xr csh 1 -.Xr ksh 1 +.Xr csh 1 , +.Xr ksh 1 , .Xr printf 1 .Sh STANDARDS The
CVS commit: src/bin/echo
Module Name:src Committed By: gutteridge Date: Wed Feb 26 02:09:46 UTC 2020 Modified Files: src/bin/echo: echo.1 Log Message: echo.1: add a note about other echo implementations The other BSDs all have a note reminding that many shells have their own internal echo implementations which may vary from this utility, so add one. (Much of the wording is borrowed from FreeBSD's man page.) (The other BSDs also have notes about the -n option not really being portable, and printf[1] being preferable, we might want to add something about that, too.) To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/bin/echo/echo.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/echo/echo.1 diff -u src/bin/echo/echo.1:1.17 src/bin/echo/echo.1:1.18 --- src/bin/echo/echo.1:1.17 Tue Jul 4 06:48:41 2017 +++ src/bin/echo/echo.1 Wed Feb 26 02:09:46 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: echo.1,v 1.17 2017/07/04 06:48:41 wiz Exp $ +.\" $NetBSD: echo.1,v 1.18 2020/02/26 02:09:46 gutteridge Exp $ .\" .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -32,7 +32,7 @@ .\" .\" @(#)echo.1 8.1 (Berkeley) 7/22/93 .\" -.Dd August 14, 2016 +.Dd February 26, 2020 .Dt ECHO 1 .Os .Sh NAME @@ -54,9 +54,20 @@ The following option is available: .It Fl n Do not print the trailing newline character. .El +.Pp +Note that many shells (e.g., +.Xr csh 1 +and +.Xr ksh 1 ) +provide a built-in +.Nm +command which tends to differ from this utility in the treatment of options +and backslashes. .Sh EXIT STATUS .Ex -std echo .Sh SEE ALSO +.Xr csh 1 +.Xr ksh 1 .Xr printf 1 .Sh STANDARDS The
CVS commit: src/bin/sh
Module Name:src Committed By: pgoyette Date: Thu Feb 20 18:24:21 UTC 2020 Modified Files: src/bin/sh: sh.1 Log Message: Typo: s/./,/ To generate a diff of this commit: cvs rdiff -u -r1.223 -r1.224 src/bin/sh/sh.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/sh.1 diff -u src/bin/sh/sh.1:1.223 src/bin/sh/sh.1:1.224 --- src/bin/sh/sh.1:1.223 Mon Apr 22 04:10:33 2019 +++ src/bin/sh/sh.1 Thu Feb 20 18:24:20 2020 @@ -1,4 +1,4 @@ -.\" $NetBSD: sh.1,v 1.223 2019/04/22 04:10:33 kre Exp $ +.\" $NetBSD: sh.1,v 1.224 2020/02/20 18:24:20 pgoyette Exp $ .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" @@ -31,7 +31,7 @@ .\" .\" @(#)sh.1 8.6 (Berkeley) 5/4/95 .\" -.Dd April 22, 2019 +.Dd February 20, 2020 .Dt SH 1 .\" everything except c o and s (keep them ordered) .ds flags abCEeFfhIiLmnpquVvXx @@ -4436,7 +4436,7 @@ and un-exportable attributes set. .Ss Dv LINENO .Dv LINENO is in many respects a normal shell variable, containing an -integer value. and can be expanded using any of the forms +integer value, and can be expanded using any of the forms mentioned above which can be used for any other variable. .Pp .Dv LINENO
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Thu Feb 13 05:19:05 UTC 2020 Modified Files: src/bin/sh: expand.c expand.h Log Message: When expanding a here-doc (NXHERE - the type with an unquoted end delim) the output will not be further processed (at all) so there is no need to escape magic chars in the output, and doing so leaves stray CTLESC chars in the here doc text. Not good. So don't do that... To save a strlen() of the result, to determine the size of the here doc, make rmescapes() return the length of the resulting string (this isn't needed for other uses, so didn't happen previously). Reported on current-users@ (2020-02-06) by Jun Ebihara XXX pullup -9 To generate a diff of this commit: cvs rdiff -u -r1.136 -r1.137 src/bin/sh/expand.c cvs rdiff -u -r1.24 -r1.25 src/bin/sh/expand.h Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/expand.c diff -u src/bin/sh/expand.c:1.136 src/bin/sh/expand.c:1.137 --- src/bin/sh/expand.c:1.136 Mon Oct 14 13:34:14 2019 +++ src/bin/sh/expand.c Thu Feb 13 05:19:05 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: expand.c,v 1.136 2019/10/14 13:34:14 christos Exp $ */ +/* $NetBSD: expand.c,v 1.137 2020/02/13 05:19:05 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)expand.c 8.5 (Berkeley) 5/15/95"; #else -__RCSID("$NetBSD: expand.c,v 1.136 2019/10/14 13:34:14 christos Exp $"); +__RCSID("$NetBSD: expand.c,v 1.137 2020/02/13 05:19:05 kre Exp $"); #endif #endif /* not lint */ @@ -146,10 +146,12 @@ STATIC void rmescapes_nl(char *); void expandhere(union node *arg, int fd) { + int len; herefd = fd; expandarg(arg, NULL, 0); - xwrite(fd, stackblock(), expdest - stackblock()); + len = rmescapes(stackblock()); + xwrite(fd, stackblock(), len); } @@ -307,7 +309,7 @@ argstr(const char *p, int flag) had_dol_at = 0; break; case CTLESC: - if (quotes || ISCTL(*p)) + if ((quotes || ISCTL(*p))) STPUTC(c, expdest); c = *p++; STPUTC(c, expdest); @@ -2037,9 +2039,11 @@ patmatch(const char *pattern, const char /* * Remove any CTLESC or CTLNONL characters from a string. + * + * String is modified in place, and we return the length of the result */ -void +int rmescapes(char *str) { char *p, *q; @@ -2047,7 +2051,7 @@ rmescapes(char *str) p = str; while (!ISCTL(*p)) { if (*p++ == '\0') - return; + return ((int)(p - str) - 1); } q = p; while (*p) { @@ -2069,6 +2073,8 @@ rmescapes(char *str) *q++ = *p++; } *q = '\0'; + + return ((int)(q - str)); } /* Index: src/bin/sh/expand.h diff -u src/bin/sh/expand.h:1.24 src/bin/sh/expand.h:1.25 --- src/bin/sh/expand.h:1.24 Sun Nov 18 17:23:37 2018 +++ src/bin/sh/expand.h Thu Feb 13 05:19:05 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: expand.h,v 1.24 2018/11/18 17:23:37 kre Exp $ */ +/* $NetBSD: expand.h,v 1.25 2020/02/13 05:19:05 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -67,5 +67,5 @@ union node; void expandhere(union node *, int); void expandarg(union node *, struct arglist *, int); -void rmescapes(char *); +int rmescapes(char *); int casematch(union node *, char *);
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Fri Feb 7 02:06:13 UTC 2020 Modified Files: src/bin/sh: jobs.c Log Message: Avoid a core dump if a child process that is not one of our children happens to exit while we are waiting for another child to exit. This can happen with code like sh -c ' sleep 5 & exec sh -c "sleep 10 & wait !$" ' when the inner "sh" is waiting for the 10 second sleep to be done, the 5 second sleep started earlier terminates. It is a child of our process, as the inner shell is the same process as the outer one, but not a known child (the inner shell has no idea what the outer one did before it started). This was observed in the wild by Martijn Dekker (where the outer shell was bash but that's irrelevant). XXX pullup -9 To generate a diff of this commit: cvs rdiff -u -r1.106 -r1.107 src/bin/sh/jobs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/jobs.c diff -u src/bin/sh/jobs.c:1.106 src/bin/sh/jobs.c:1.107 --- src/bin/sh/jobs.c:1.106 Tue Mar 26 13:32:26 2019 +++ src/bin/sh/jobs.c Fri Feb 7 02:06:12 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: jobs.c,v 1.106 2019/03/26 13:32:26 kre Exp $ */ +/* $NetBSD: jobs.c,v 1.107 2020/02/07 02:06:12 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)jobs.c 8.5 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: jobs.c,v 1.106 2019/03/26 13:32:26 kre Exp $"); +__RCSID("$NetBSD: jobs.c,v 1.107 2020/02/07 02:06:12 kre Exp $"); #endif #endif /* not lint */ @@ -820,6 +820,9 @@ waitcmd(int argc, char **argv) if ((i = dowait(WBLOCK|WNOFREE, NULL, )) == -1) return 128 + lastsig(); + if (job == NULL) /* an interloper */ +continue; + /* * one of the job's processes exited, * but there are more
CVS commit: src/bin/sh
Module Name:src Committed By: fox Date: Fri Feb 7 01:25:08 UTC 2020 Modified Files: src/bin/sh: main.c Log Message: bin/sh: Fixes -Werror=shadow causing build breaks. Conflicting variable name, sigset_t sigs has been renamed to sigset_t mask Reviewed by: kamil@ To generate a diff of this commit: cvs rdiff -u -r1.84 -r1.85 src/bin/sh/main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/main.c diff -u src/bin/sh/main.c:1.84 src/bin/sh/main.c:1.85 --- src/bin/sh/main.c:1.84 Thu Feb 6 20:08:28 2020 +++ src/bin/sh/main.c Fri Feb 7 01:25:08 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.84 2020/02/06 20:08:28 kre Exp $ */ +/* $NetBSD: main.c,v 1.85 2020/02/07 01:25:08 fox Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 19 #if 0 static char sccsid[] = "@(#)main.c 8.7 (Berkeley) 7/19/95"; #else -__RCSID("$NetBSD: main.c,v 1.84 2020/02/06 20:08:28 kre Exp $"); +__RCSID("$NetBSD: main.c,v 1.85 2020/02/07 01:25:08 fox Exp $"); #endif #endif /* not lint */ @@ -108,7 +108,7 @@ main(int argc, char **argv) char *shinit; uid_t uid; gid_t gid; - sigset_t sigs; + sigset_t mask; /* * If we happen to be invoked with SIGCHLD ignored, we cannot @@ -121,9 +121,9 @@ main(int argc, char **argv) /* * Similarly, SIGCHLD must not be blocked */ - sigemptyset(); - sigaddset(, SIGCHLD); - sigprocmask(SIG_UNBLOCK, , NULL); + sigemptyset(); + sigaddset(, SIGCHLD); + sigprocmask(SIG_UNBLOCK, , NULL); uid = getuid(); gid = getgid();
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Thu Feb 6 20:08:28 UTC 2020 Modified Files: src/bin/sh: main.c Log Message: Actually, the issue with bash (in previous) is more likely that the SIGCHLD is blocked rather than ignored. We want neither. Make sure SIGCHLD is unblocked as well as SIG_DFL. XXX pullup -9 To generate a diff of this commit: cvs rdiff -u -r1.83 -r1.84 src/bin/sh/main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/main.c diff -u src/bin/sh/main.c:1.83 src/bin/sh/main.c:1.84 --- src/bin/sh/main.c:1.83 Thu Feb 6 19:51:59 2020 +++ src/bin/sh/main.c Thu Feb 6 20:08:28 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.83 2020/02/06 19:51:59 kre Exp $ */ +/* $NetBSD: main.c,v 1.84 2020/02/06 20:08:28 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 19 #if 0 static char sccsid[] = "@(#)main.c 8.7 (Berkeley) 7/19/95"; #else -__RCSID("$NetBSD: main.c,v 1.83 2020/02/06 19:51:59 kre Exp $"); +__RCSID("$NetBSD: main.c,v 1.84 2020/02/06 20:08:28 kre Exp $"); #endif #endif /* not lint */ @@ -108,6 +108,7 @@ main(int argc, char **argv) char *shinit; uid_t uid; gid_t gid; + sigset_t sigs; /* * If we happen to be invoked with SIGCHLD ignored, we cannot @@ -117,6 +118,12 @@ main(int argc, char **argv) * footpath for someone else to fall into... */ (void)signal(SIGCHLD, SIG_DFL); + /* + * Similarly, SIGCHLD must not be blocked + */ + sigemptyset(); + sigaddset(, SIGCHLD); + sigprocmask(SIG_UNBLOCK, , NULL); uid = getuid(); gid = getgid();
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Thu Feb 6 19:51:59 UTC 2020 Modified Files: src/bin/sh: main.c Log Message: If we are invoked with SIGCHLD ignored, we fail badly, as we assume that we can always wait(2) for our children, and an ignored SIGCHLD prevents that. Recent versions of bash can be convinced (due to a bug most likely) to invoke us that way. Always return SIGCHLD to SIG_DFL during init - we already prevent scripts from fiddling it. All ash derived shells apparently have this problem (observed by Martijn Dekker, and notified on the bash-bug list). Actual issue diagnosed by Harald van Dijk (same list). To generate a diff of this commit: cvs rdiff -u -r1.82 -r1.83 src/bin/sh/main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/main.c diff -u src/bin/sh/main.c:1.82 src/bin/sh/main.c:1.83 --- src/bin/sh/main.c:1.82 Sat Feb 9 09:33:20 2019 +++ src/bin/sh/main.c Thu Feb 6 19:51:59 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.82 2019/02/09 09:33:20 kre Exp $ */ +/* $NetBSD: main.c,v 1.83 2020/02/06 19:51:59 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 19 #if 0 static char sccsid[] = "@(#)main.c 8.7 (Berkeley) 7/19/95"; #else -__RCSID("$NetBSD: main.c,v 1.82 2019/02/09 09:33:20 kre Exp $"); +__RCSID("$NetBSD: main.c,v 1.83 2020/02/06 19:51:59 kre Exp $"); #endif #endif /* not lint */ @@ -109,6 +109,15 @@ main(int argc, char **argv) uid_t uid; gid_t gid; + /* + * If we happen to be invoked with SIGCHLD ignored, we cannot + * successfully do almost anything. Perhaps we should remember + * its state and pass it on ignored to children if it was ignored + * on entry, but that seems like just leaving the shit on the + * footpath for someone else to fall into... + */ + (void)signal(SIGCHLD, SIG_DFL); + uid = getuid(); gid = getgid();
CVS commit: src/bin/csh
Module Name:src Committed By: fox Date: Wed Feb 5 20:06:17 UTC 2020 Modified Files: src/bin/csh: sem.c Log Message: bin/csh: Fix the -Wclobber warning. Mark the variable as volatile as it can be clobbered when a vfork occurs. Error was reported when build.sh was run with MKLIBCSANITIZER=yes flag. Reviewed by: kamil@ To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/bin/csh/sem.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/csh/sem.c diff -u src/bin/csh/sem.c:1.31 src/bin/csh/sem.c:1.32 --- src/bin/csh/sem.c:1.31 Sat Jan 5 16:54:00 2019 +++ src/bin/csh/sem.c Wed Feb 5 20:06:17 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sem.c,v 1.31 2019/01/05 16:54:00 christos Exp $ */ +/* $NetBSD: sem.c,v 1.32 2020/02/05 20:06:17 fox Exp $ */ /*- * Copyright (c) 1980, 1991, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)sem.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: sem.c,v 1.31 2019/01/05 16:54:00 christos Exp $"); +__RCSID("$NetBSD: sem.c,v 1.32 2020/02/05 20:06:17 fox Exp $"); #endif #endif /* not lint */ @@ -67,7 +67,7 @@ execute(struct command *t, int wtty, int struct biltins * volatile bifunc; int pv[2], pid; sigset_t nsigset; -int forked; +volatile int forked; UNREGISTER(forked); UNREGISTER(bifunc);
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Wed Feb 5 14:56:26 UTC 2020 Modified Files: src/bin/sh: options.c Log Message: Oops, the previous didn't do what was promised. Rather that ignoring just "--" for exec & "." it ignored any first arg starting '-'. Do it properly. To generate a diff of this commit: cvs rdiff -u -r1.54 -r1.55 src/bin/sh/options.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/options.c diff -u src/bin/sh/options.c:1.54 src/bin/sh/options.c:1.55 --- src/bin/sh/options.c:1.54 Tue Feb 4 16:06:59 2020 +++ src/bin/sh/options.c Wed Feb 5 14:56:25 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: options.c,v 1.54 2020/02/04 16:06:59 kre Exp $ */ +/* $NetBSD: options.c,v 1.55 2020/02/05 14:56:25 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)options.c 8.2 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: options.c,v 1.54 2020/02/04 16:06:59 kre Exp $"); +__RCSID("$NetBSD: options.c,v 1.55 2020/02/05 14:56:25 kre Exp $"); #endif #endif /* not lint */ @@ -616,6 +616,8 @@ nextopt(const char *optstring) argptr++; if (p[0] == '-' && p[1] == '\0') /* check for "--" */ return '\0'; + if (optstring == NULL) /* not processing the "option" */ + argptr--; /* so make it be an arg again */ } if (optstring == NULL) return '\0';
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Tue Feb 4 16:06:59 UTC 2020 Modified Files: src/bin/sh: eval.c options.c Log Message: After bug report 262 (from 2010) https://austingroupbugs.net/view.php?id=252 the Austin Group decided to require processing of "--" by the "." and "exec" commands to solve a problem where some shells did option processing for those commands (permitted) and others did not (also permitted) which left no safe way to process a file with a name beginning with "-". This has finally made its way into what will be the next version of the POSIX standard. Since this shell did no option processing at all for those commands, we need to update. This is that update. The sole effect is that a "--" 'option' (to "." or "exec") is ignored. This means that if you want to use "--" as the arg to one of those commands, it needs to be given twice ". -- --". Apart from that there should be no difference at all (though the "--" can now be used in other situations, where we did not require it before, and still do not). To generate a diff of this commit: cvs rdiff -u -r1.177 -r1.178 src/bin/sh/eval.c cvs rdiff -u -r1.53 -r1.54 src/bin/sh/options.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/eval.c diff -u src/bin/sh/eval.c:1.177 src/bin/sh/eval.c:1.178 --- src/bin/sh/eval.c:1.177 Sat Dec 21 18:54:15 2019 +++ src/bin/sh/eval.c Tue Feb 4 16:06:59 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: eval.c,v 1.177 2019/12/21 18:54:15 kre Exp $ */ +/* $NetBSD: eval.c,v 1.178 2020/02/04 16:06:59 kre Exp $ */ /*- * Copyright (c) 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95"; #else -__RCSID("$NetBSD: eval.c,v 1.177 2019/12/21 18:54:15 kre Exp $"); +__RCSID("$NetBSD: eval.c,v 1.178 2020/02/04 16:06:59 kre Exp $"); #endif #endif /* not lint */ @@ -1493,7 +1493,9 @@ dotcmd(int argc, char **argv) { exitstatus = 0; - if (argc >= 2) { /* That's what SVR2 does */ + (void) nextopt(NULL); /* ignore a leading "--" */ + + if (*argptr != NULL) { /* That's what SVR2 does */ char *fullname; /* * dot_funcnest needs to be 0 when not in a dotcmd, so it @@ -1503,7 +1505,7 @@ dotcmd(int argc, char **argv) struct stackmark smark; setstackmark(); - fullname = find_dot_file(argv[1]); + fullname = find_dot_file(*argptr); setinputfile(fullname, 1); commandname = fullname; dot_funcnest_old = dot_funcnest; @@ -1649,7 +1651,9 @@ truecmd(int argc, char **argv) int execcmd(int argc, char **argv) { - if (argc > 1) { + (void) nextopt(NULL); /* ignore a leading "--" */ + + if (*argptr) { struct strlist *sp; iflag = 0; /* exit on error */ @@ -1657,7 +1661,7 @@ execcmd(int argc, char **argv) optschanged(); for (sp = cmdenviron; sp; sp = sp->next) setvareq(sp->text, VDOEXPORT|VEXPORT|VSTACK); - shellexec(argv + 1, environment(), pathval(), 0, 0); + shellexec(argptr, environment(), pathval(), 0, 0); } return 0; } Index: src/bin/sh/options.c diff -u src/bin/sh/options.c:1.53 src/bin/sh/options.c:1.54 --- src/bin/sh/options.c:1.53 Fri Jul 13 22:43:44 2018 +++ src/bin/sh/options.c Tue Feb 4 16:06:59 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: options.c,v 1.53 2018/07/13 22:43:44 kre Exp $ */ +/* $NetBSD: options.c,v 1.54 2020/02/04 16:06:59 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)options.c 8.2 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: options.c,v 1.53 2018/07/13 22:43:44 kre Exp $"); +__RCSID("$NetBSD: options.c,v 1.54 2020/02/04 16:06:59 kre Exp $"); #endif #endif /* not lint */ @@ -595,7 +595,11 @@ out: * Standard option processing (a la getopt) for builtin routines. The * only argument that is passed to nextopt is the option string; the * other arguments are unnecessary. It return the character, or '\0' on - * end of input. + * end of input. If optstring is NULL, then there are no options, and + * args are allowed to begin with '-', but a single leading "--" will be + * discarded. This is for some POSIX special builtins that require + * -- processing, have no args, and we never did opt processing before + * and need to retain backwards compat. */ int @@ -613,6 +617,8 @@ nextopt(const char *optstring) if (p[0] == '-' && p[1] == '\0') /* check for "--" */ return '\0'; } + if (optstring == NULL) + return '\0'; c = *p++; for (q = optstring ; *q != c ; ) { if (*q == '\0')
CVS commit: src/bin/csh
Module Name:src Committed By: christos Date: Sun Jan 12 18:42:41 UTC 2020 Modified Files: src/bin/csh: set.c Log Message: Add file completion. To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/bin/csh/set.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/csh/set.c diff -u src/bin/csh/set.c:1.36 src/bin/csh/set.c:1.37 --- src/bin/csh/set.c:1.36 Sat Jan 11 22:50:30 2020 +++ src/bin/csh/set.c Sun Jan 12 13:42:41 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: set.c,v 1.36 2020/01/12 03:50:30 christos Exp $ */ +/* $NetBSD: set.c,v 1.37 2020/01/12 18:42:41 christos Exp $ */ /*- * Copyright (c) 1980, 1991, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)set.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: set.c,v 1.36 2020/01/12 03:50:30 christos Exp $"); +__RCSID("$NetBSD: set.c,v 1.37 2020/01/12 18:42:41 christos Exp $"); #endif #endif /* not lint */ @@ -43,9 +43,7 @@ __RCSID("$NetBSD: set.c,v 1.36 2020/01/1 #include #include -#ifndef SHORT_STRINGS #include -#endif /* SHORT_STRINGS */ #include "csh.h" #include "extern.h" @@ -61,6 +59,41 @@ static void unsetv1(struct varent *); static void exportpath(Char **); static void balance(struct varent *, int, int); +#ifdef EDIT +static const char * +alias_text(void *dummy __unused, const char *name) +{ + static char *buf; + struct varent *vp; + Char **av; + char *p; + size_t len; + + vp = adrof1(str2short(name), ); + if (vp == NULL) + return NULL; + + len = 0; + for (av = vp->vec; *av; av++) { + len += strlen(vis_str(*av)); + if (av[1]) + len++; + } + len++; + free(buf); + p = buf = xmalloc(len); + for (av = vp->vec; *av; av++) { + const char *s = vis_str(*av); + while ((*p++ = *s++) != '\0') + continue; + if (av[1]) + *p++ = ' '; + } + *p = '\0'; + return buf; +} +#endif + /* * C Shell */ @@ -124,6 +157,11 @@ update_vars(Char *vp) SHIN, SHOUT, SHERR); el_set(el, EL_EDITOR, *vn ? short2str(vn) : "emacs"); el_set(el, EL_PROMPT, printpromptstr); + el_set(el, EL_ALIAS_TEXT, alias_text, NULL); + el_set(el, EL_ADDFN, "rl-complete", + "ReadLine compatible completion function", _el_fn_complete); + el_set(el, EL_BIND, "^I", adrof(STRfilec) ? "rl-complete" : "ed-insert", + NULL); hi = history_init(); history(hi, , H_SETSIZE, getn(value(STRhistory))); loadhist(Histlist.Hnext);
CVS commit: src/bin/csh
Module Name:src Committed By: christos Date: Sun Jan 12 18:36:55 UTC 2020 Modified Files: src/bin/csh: csh.c Log Message: remove unused To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/bin/csh/csh.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/csh/csh.c diff -u src/bin/csh/csh.c:1.48 src/bin/csh/csh.c:1.49 --- src/bin/csh/csh.c:1.48 Sat Jan 5 11:54:00 2019 +++ src/bin/csh/csh.c Sun Jan 12 13:36:55 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: csh.c,v 1.48 2019/01/05 16:54:00 christos Exp $ */ +/* $NetBSD: csh.c,v 1.49 2020/01/12 18:36:55 christos Exp $ */ /*- * Copyright (c) 1980, 1991, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19 #if 0 static char sccsid[] = "@(#)csh.c 8.2 (Berkeley) 10/12/93"; #else -__RCSID("$NetBSD: csh.c,v 1.48 2019/01/05 16:54:00 christos Exp $"); +__RCSID("$NetBSD: csh.c,v 1.49 2020/01/12 18:36:55 christos Exp $"); #endif #endif /* not lint */ @@ -105,9 +105,6 @@ static void mailchk(void); #ifndef _PATH_DEFPATH static Char **defaultpath(void); #endif -#ifdef EDITING -int editing = 0; -#endif int main(int argc, char *argv[])
CVS commit: src/bin/csh
Module Name:src Committed By: christos Date: Sun Jan 12 03:50:30 UTC 2020 Modified Files: src/bin/csh: set.c Log Message: PR/54853: Greg Oster: unable to 'unset filec' or 'unset edit' in csh While here allow set edit=vi To generate a diff of this commit: cvs rdiff -u -r1.35 -r1.36 src/bin/csh/set.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/csh/set.c diff -u src/bin/csh/set.c:1.35 src/bin/csh/set.c:1.36 --- src/bin/csh/set.c:1.35 Sat Jan 5 11:54:00 2019 +++ src/bin/csh/set.c Sat Jan 11 22:50:30 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: set.c,v 1.35 2019/01/05 16:54:00 christos Exp $ */ +/* $NetBSD: set.c,v 1.36 2020/01/12 03:50:30 christos Exp $ */ /*- * Copyright (c) 1980, 1991, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)set.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: set.c,v 1.35 2019/01/05 16:54:00 christos Exp $"); +__RCSID("$NetBSD: set.c,v 1.36 2020/01/12 03:50:30 christos Exp $"); #endif #endif /* not lint */ @@ -117,10 +117,12 @@ update_vars(Char *vp) #ifdef EDIT else if (eq(vp, STRedit)) { HistEvent ev; + Char *vn = value(STRhistchars); + editing = 1; el = el_init_fd(getprogname(), cshin, cshout, csherr, SHIN, SHOUT, SHERR); - el_set(el, EL_EDITOR, "emacs"); + el_set(el, EL_EDITOR, *vn ? short2str(vn) : "emacs"); el_set(el, EL_PROMPT, printpromptstr); hi = history_init(); history(hi, , H_SETSIZE, getn(value(STRhistory))); @@ -518,16 +520,18 @@ unset(Char **v, struct command *t) HIST = '!'; HISTSUB = '^'; } -else if (adrof(STRwordchars) == 0) +if (adrof(STRwordchars) == 0) word_chars = STR_WORD_CHARS; #ifdef FILEC -else if (adrof(STRfilec) == 0) +if (adrof(STRfilec) == 0) filec = 0; #endif #ifdef EDIT -else if (adrof(STRedit) == 0) { - el_end(el); - history_end(hi); +if (adrof(STRedit) == 0) { + if (el) + el_end(el); + if (hi) + history_end(hi); el = NULL; hi = NULL; editing = 0;
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Sat Dec 21 18:54:15 UTC 2019 Modified Files: src/bin/sh: eval.c Log Message: Use fork() rather than vfork() when forking to run a background process with redirects. If we use vfork() and a redirect hangs (eg: opening a fifo) which the parent was intended to unhang, then the parent never gets to continue to unhang the child. eg: mkfifo f; cat f The parent should not be waiting for a background process, even just for its exec() to complete. if there are no redirects there is (should be) nothing left that might be done that will cause any noticeable delay, so vfork() should be safe in all other cases. To generate a diff of this commit: cvs rdiff -u -r1.176 -r1.177 src/bin/sh/eval.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/eval.c diff -u src/bin/sh/eval.c:1.176 src/bin/sh/eval.c:1.177 --- src/bin/sh/eval.c:1.176 Mon Dec 9 00:14:24 2019 +++ src/bin/sh/eval.c Sat Dec 21 18:54:15 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: eval.c,v 1.176 2019/12/09 00:14:24 kre Exp $ */ +/* $NetBSD: eval.c,v 1.177 2019/12/21 18:54:15 kre Exp $ */ /*- * Copyright (c) 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95"; #else -__RCSID("$NetBSD: eval.c,v 1.176 2019/12/09 00:14:24 kre Exp $"); +__RCSID("$NetBSD: eval.c,v 1.177 2019/12/21 18:54:15 kre Exp $"); #endif #endif /* not lint */ @@ -552,8 +552,8 @@ evalsubshell(union node *n, int flags) forkshell(jp = makejob(n, 1), n, backgnd?FORK_BG:FORK_FG) == 0) { if (backgnd) flags &=~ EV_TESTED; - redirect(n->nredir.redirect, REDIR_KEEP); INTON; + redirect(n->nredir.redirect, REDIR_KEEP); evaltree(n->nredir.n, flags | EV_EXIT); /* never returns */ } else if (backgnd) exitstatus = 0; @@ -1086,7 +1086,8 @@ evalcommand(union node *cmd, int flgs, s * child's address space is actually shared with the parent as * we rely on this. */ - if (usefork == 0 && cmdentry.cmdtype == CMDNORMAL) { + if (usefork == 0 && cmdentry.cmdtype == CMDNORMAL && + (!cmd->ncmd.backgnd || cmd->ncmd.redirect == NULL)) { pid_t pid; int serrno;
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Tue Dec 10 09:18:37 UTC 2019 Modified Files: src/bin/sh: parser.c Log Message: Correct a typo in a comment, 08x0 was meant to be 0x80 (duh!). NFC. To generate a diff of this commit: cvs rdiff -u -r1.168 -r1.169 src/bin/sh/parser.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/parser.c diff -u src/bin/sh/parser.c:1.168 src/bin/sh/parser.c:1.169 --- src/bin/sh/parser.c:1.168 Sat May 4 02:52:22 2019 +++ src/bin/sh/parser.c Tue Dec 10 09:18:37 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: parser.c,v 1.168 2019/05/04 02:52:22 kre Exp $ */ +/* $NetBSD: parser.c,v 1.169 2019/12/10 09:18:37 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)parser.c 8.7 (Berkeley) 5/16/95"; #else -__RCSID("$NetBSD: parser.c,v 1.168 2019/05/04 02:52:22 kre Exp $"); +__RCSID("$NetBSD: parser.c,v 1.169 2019/12/10 09:18:37 kre Exp $"); #endif #endif /* not lint */ @@ -1749,7 +1749,7 @@ readcstyleesc(char *out) * * The current definition of ISCTL() allows the compiler to * optimise away either half, or all, of the test in most of - * the cases here (0xc0 | anything) cannot be between 08x0 and 0x9f + * the cases here (0xc0 | anything) cannot be between 0x80 and 0x9f * for example, so there a test is not needed). * * Which tests can be removed depends upon the actual values
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Mon Dec 9 00:14:30 UTC 2019 Modified Files: src/bin/sh: trap.c Log Message: PR bin/54743 If a builtin command or function is the final command intended to be executed, and is interrupted by a caught signal, the trap handler for that signal was not executed - the shell simply exited (an exit trap handler would still have been run - if there was one the handler for the signal may have been invoked during the execution of the exit trap handler, which, if it happened, is incorrect sequencing). Now, if we're exiting, and there are pending signals, run their handlers just before running the EXIT trap handler, if any. There are almost certainly plenty more issues with traps that need solving. Later, XXX pullup -9 (-8 is too different in this area, and this problem suitably obscure, that we won't bother) (the -7 sh is simply obsolete). To generate a diff of this commit: cvs rdiff -u -r1.52 -r1.53 src/bin/sh/trap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/trap.c diff -u src/bin/sh/trap.c:1.52 src/bin/sh/trap.c:1.53 --- src/bin/sh/trap.c:1.52 Thu Apr 25 03:54:10 2019 +++ src/bin/sh/trap.c Mon Dec 9 00:14:30 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.52 2019/04/25 03:54:10 kre Exp $ */ +/* $NetBSD: trap.c,v 1.53 2019/12/09 00:14:30 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)trap.c 8.5 (Berkeley) 6/5/95"; #else -__RCSID("$NetBSD: trap.c,v 1.52 2019/04/25 03:54:10 kre Exp $"); +__RCSID("$NetBSD: trap.c,v 1.53 2019/12/09 00:14:30 kre Exp $"); #endif #endif /* not lint */ @@ -854,6 +854,12 @@ exitshell_savedstatus(void) } exitstatus = exiting_status; + if (pendingsigs && !setjmp(loc.loc)) { + handler = + + dotrap(); + } + if (!setjmp(loc.loc)) { handler =
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Mon Dec 9 00:14:24 UTC 2019 Modified Files: src/bin/sh: eval.c Log Message: PR bin/54743 Having traps set should not enforce a fork for the next command, whatever that command happens to be, only for commands which would normally fork if they weren't the last command expected to be executed (ie: builtins and functions shouldn't be exexuted in a sub-shell merely because a trap is set). As it was (for example) trap 'whatever' SIGANY; wait $anypid was guaranteed to fail the wait, as the subshell it was executed in could not have any children. XXX pullup -9 To generate a diff of this commit: cvs rdiff -u -r1.175 -r1.176 src/bin/sh/eval.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/eval.c diff -u src/bin/sh/eval.c:1.175 src/bin/sh/eval.c:1.176 --- src/bin/sh/eval.c:1.175 Sat May 4 02:52:55 2019 +++ src/bin/sh/eval.c Mon Dec 9 00:14:24 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: eval.c,v 1.175 2019/05/04 02:52:55 kre Exp $ */ +/* $NetBSD: eval.c,v 1.176 2019/12/09 00:14:24 kre Exp $ */ /*- * Copyright (c) 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95"; #else -__RCSID("$NetBSD: eval.c,v 1.175 2019/05/04 02:52:55 kre Exp $"); +__RCSID("$NetBSD: eval.c,v 1.176 2019/12/09 00:14:24 kre Exp $"); #endif #endif /* not lint */ @@ -1061,13 +1061,18 @@ evalcommand(union node *cmd, int flgs, s free_traps(); /* Fork off a child process if necessary. */ - if (cmd->ncmd.backgnd || (have_traps() && (flags & EV_EXIT) != 0) - || ((cmdentry.cmdtype == CMDNORMAL || cmdentry.cmdtype == CMDUNKNOWN) - && (flags & EV_EXIT) == 0) - || ((flags & EV_BACKCMD) != 0 && - ((cmdentry.cmdtype != CMDBUILTIN && cmdentry.cmdtype != CMDSPLBLTIN) - || cmdentry.u.bltin == dotcmd - || cmdentry.u.bltin == evalcmd))) { + if (cmd->ncmd.backgnd + || ((cmdentry.cmdtype == CMDNORMAL || cmdentry.cmdtype == CMDUNKNOWN) + && (have_traps() || (flags & EV_EXIT) == 0)) +#ifdef notyet /* EV_BACKCMD is never set currently */ + /* this will need more work if/when it gets used */ + || ((flags & EV_BACKCMD) != 0 + && (cmdentry.cmdtype != CMDBUILTIN + && cmdentry.cmdtype != CMDSPLBLTIN) + || cmdentry.u.bltin == dotcmd + || cmdentry.u.bltin == evalcmd) +#endif + ) { INTOFF; jp = makejob(cmd, 1); mode = cmd->ncmd.backgnd;
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Sat May 4 02:52:55 UTC 2019 Modified Files: src/bin/sh: eval.c Log Message: When a return occurs in the test part of a loop statement (while/until) (inside a function or dot script) the exit status of that return statement should become the exit status of the function (or dot script) - we were ignoring it, That is fn() { while return 7; do return 9; done; return 11; } should exit with status 7. It was exiting 0. This is apparently another old ash bug that has been fixed everywhere else in the past. Issue pointed out by Martijn Dekker, (fairly obvious) fix borrowed from FreeBSD, due for return sometime next century. To generate a diff of this commit: cvs rdiff -u -r1.174 -r1.175 src/bin/sh/eval.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/eval.c diff -u src/bin/sh/eval.c:1.174 src/bin/sh/eval.c:1.175 --- src/bin/sh/eval.c:1.174 Sat Feb 9 09:17:59 2019 +++ src/bin/sh/eval.c Sat May 4 02:52:55 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: eval.c,v 1.174 2019/02/09 09:17:59 kre Exp $ */ +/* $NetBSD: eval.c,v 1.175 2019/05/04 02:52:55 kre Exp $ */ /*- * Copyright (c) 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)eval.c 8.9 (Berkeley) 6/8/95"; #else -__RCSID("$NetBSD: eval.c,v 1.174 2019/02/09 09:17:59 kre Exp $"); +__RCSID("$NetBSD: eval.c,v 1.175 2019/05/04 02:52:55 kre Exp $"); #endif #endif /* not lint */ @@ -407,6 +407,8 @@ evalloop(union node *n, int flags) } if (evalskip == SKIPBREAK && --skipcount <= 0) evalskip = SKIPNONE; + if (evalskip == SKIPFUNC || evalskip == SKIPFILE) +status = exitstatus; break; } if (n->type == NWHILE) {
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Thu Apr 25 03:54:10 UTC 2019 Modified Files: src/bin/sh: trap.c Log Message: Better interactive SIGINT handling (when a trap is set), and other cleanups to the trap code. No longer silently ignore attempts to do anything other than set SIGKILL or SIGSTOP to the default ('-") state. Don't include those in trap or trap -p output (the former because they cannot be other than in default state, so simply aren't included, the latter because it is pointless) but do list them when requested with trap -p SIG. Interactive mode SIGINT traps are now run ASAP, rather than after a command has been entered (so the sequence ^C \n is no longer needed to generate one). Further, when trapped, in interactive mode, while waiting for a user command, a SIGINT acts (aside from the trap being run) just like when not trapped, aborts the command being entered (rather than leaving it, which it did when libedit was in use) prints a new prompt, and starts again (which is what should happen.) Traps other than SIGINT (which has always been handled special in interactive mode) are unaffected by this change, as are SIGINT traps in non-interactive shells.Or that is the intent anyway. Fix an in_dotrap ref count bug (was never being decremented... that was inserted in a place never executed) (relatively harmless) and add/improve some trap/signal related DEBUG mode tracing. To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/bin/sh/trap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/trap.c diff -u src/bin/sh/trap.c:1.51 src/bin/sh/trap.c:1.52 --- src/bin/sh/trap.c:1.51 Fri Jan 18 06:28:09 2019 +++ src/bin/sh/trap.c Thu Apr 25 03:54:10 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.51 2019/01/18 06:28:09 kre Exp $ */ +/* $NetBSD: trap.c,v 1.52 2019/04/25 03:54:10 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)trap.c 8.5 (Berkeley) 6/5/95"; #else -__RCSID("$NetBSD: trap.c,v 1.51 2019/01/18 06:28:09 kre Exp $"); +__RCSID("$NetBSD: trap.c,v 1.52 2019/04/25 03:54:10 kre Exp $"); #endif #endif /* not lint */ @@ -46,6 +46,7 @@ __RCSID("$NetBSD: trap.c,v 1.51 2019/01/ #include #include #include +#include #include #undef CEOF /* from but concflicts with sh use */ @@ -269,7 +270,9 @@ trapcmd(int argc, char **argv) CTRACE(DBG_TRAP, ("*all*\n")); if (printonly) { - for (count = 0, signo = 0 ; signo < NSIG ; signo++) + for (count = 0, signo = 0 ; signo < NSIG ; signo++) { +if (signo == SIGKILL || signo == SIGSTOP) + continue; if (trap[signo] == NULL) { if (count == 0) out1str("trap -- -"); @@ -280,10 +283,16 @@ trapcmd(int argc, char **argv) count = 0; } } + } if (count) out1str("\n"); } + /* + * We don't need do deal with SIGSTOP or SIGKILL as a + * special case anywhere here, as they cannot be + * ignored or caught - the only possibility is default + */ for (count = 0, signo = 0 ; signo < NSIG ; signo++) if (trap[signo] != NULL && trap[signo][0] == '\0') { if (count == 0) @@ -351,6 +360,11 @@ trapcmd(int argc, char **argv) ap++; if (printonly) { + /* + * we allow SIGSTOP and SIGKILL to be obtained + * (action will always be "-") here, if someone + * really wants to get that particular output + */ out1str("trap -- "); if (trap[signo] == NULL) out1str("-"); @@ -360,6 +374,27 @@ trapcmd(int argc, char **argv) continue; } + if ((signo == SIGKILL || signo == SIGSTOP) && action != NULL) { +#ifndef SMALL + /* + * Don't bother with the error message in a SMALL shell + * just ignore req and return error status silently + * (POSIX says this is an "undefined" operation so + * whatever we do is OK!) + * + * When we do generate an error, make it attempt match + * the user's operand, as best we can reasonably. + */ + outfmt(out2, "trap: '%s%s' cannot be %s\n", + (!is_alpha(ap[-1][0]) || +strncasecmp(ap[-1], "sig", 3) == 0) ? "" : +is_upper(ap[-1][0]) ? "SIG" : "sig", + ap[-1], *action ? "caught" : "ignored"); +#endif + errs = 1; + continue; + } + INTOFF; if (action) action = savestr(action); @@ -647,15 +682,23 @@ SHELLPROC { void onsig(int signo) { - CTRACE(DBG_SIG, ("Signal %d, had: pending %d, gotsig[%d]=%d\n", - signo, pendingsigs, signo, gotsig[signo])); + int sav_err = errno; + + CTRACE(DBG_SIG, ("onsig(%d), had: pendingsigs %d%s, gotsig[%d]=%d\n", + signo, pendingsigs, intpending ? " (SIGINT-pending)" : "", + signo, gotsig[signo])); /* This should not be needed. signal(signo, onsig); */ if (signo == SIGINT && (traps_invalid || trap[SIGINT] == NULL)) { - onint(); + VTRACE(DBG_SIG, ("onsig(SIGINT), doing it now\n")); + if (suppressint && !in_dotrap) + intpending =
CVS commit: src/bin/pax
Module Name:src Committed By: cheusov Date: Wed Apr 24 17:27:08 UTC 2019 Modified Files: src/bin/pax: pax.c Log Message: Fix compilation failure with gcc-8. Equal pointers to 'struct sigaction' should not be passed to sigaction(2). So, we pass NULL as an "old sigaction" structure. To generate a diff of this commit: cvs rdiff -u -r1.48 -r1.49 src/bin/pax/pax.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/pax/pax.c diff -u src/bin/pax/pax.c:1.48 src/bin/pax/pax.c:1.49 --- src/bin/pax/pax.c:1.48 Mon Oct 2 21:55:35 2017 +++ src/bin/pax/pax.c Wed Apr 24 17:27:08 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: pax.c,v 1.48 2017/10/02 21:55:35 joerg Exp $ */ +/* $NetBSD: pax.c,v 1.49 2019/04/24 17:27:08 cheusov Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -44,7 +44,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 19 #if 0 static char sccsid[] = "@(#)pax.c 8.2 (Berkeley) 4/18/94"; #else -__RCSID("$NetBSD: pax.c,v 1.48 2017/10/02 21:55:35 joerg Exp $"); +__RCSID("$NetBSD: pax.c,v 1.49 2019/04/24 17:27:08 cheusov Exp $"); #endif #endif /* not lint */ @@ -453,28 +453,28 @@ gen_init(void) if ((sigaction(SIGHUP, _hand, _hand) < 0) && (o_hand.sa_handler == SIG_IGN) && - (sigaction(SIGHUP, _hand, _hand) < 0)) + (sigaction(SIGHUP, _hand, NULL) < 0)) goto out; if ((sigaction(SIGTERM, _hand, _hand) < 0) && (o_hand.sa_handler == SIG_IGN) && - (sigaction(SIGTERM, _hand, _hand) < 0)) + (sigaction(SIGTERM, _hand, NULL) < 0)) goto out; if ((sigaction(SIGINT, _hand, _hand) < 0) && (o_hand.sa_handler == SIG_IGN) && - (sigaction(SIGINT, _hand, _hand) < 0)) + (sigaction(SIGINT, _hand, NULL) < 0)) goto out; if ((sigaction(SIGQUIT, _hand, _hand) < 0) && (o_hand.sa_handler == SIG_IGN) && - (sigaction(SIGQUIT, _hand, _hand) < 0)) + (sigaction(SIGQUIT, _hand, NULL) < 0)) goto out; #ifdef SIGXCPU if ((sigaction(SIGXCPU, _hand, _hand) < 0) && (o_hand.sa_handler == SIG_IGN) && - (sigaction(SIGXCPU, _hand, _hand) < 0)) + (sigaction(SIGXCPU, _hand, NULL) < 0)) goto out; #endif n_hand.sa_handler = SIG_IGN;
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Mon Apr 22 04:10:33 UTC 2019 Modified Files: src/bin/sh: sh.1 Log Message: Bump date for previous. To generate a diff of this commit: cvs rdiff -u -r1.222 -r1.223 src/bin/sh/sh.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/sh.1 diff -u src/bin/sh/sh.1:1.222 src/bin/sh/sh.1:1.223 --- src/bin/sh/sh.1:1.222 Mon Apr 22 04:04:35 2019 +++ src/bin/sh/sh.1 Mon Apr 22 04:10:33 2019 @@ -1,4 +1,4 @@ -.\" $NetBSD: sh.1,v 1.222 2019/04/22 04:04:35 kre Exp $ +.\" $NetBSD: sh.1,v 1.223 2019/04/22 04:10:33 kre Exp $ .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" @@ -31,7 +31,7 @@ .\" .\" @(#)sh.1 8.6 (Berkeley) 5/4/95 .\" -.Dd February 14, 2019 +.Dd April 22, 2019 .Dt SH 1 .\" everything except c o and s (keep them ordered) .ds flags abCEeFfhIiLmnpquVvXx
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Mon Apr 22 04:04:36 UTC 2019 Modified Files: src/bin/sh: sh.1 Log Message: PR standards/40554 Update the description of the <& and >& redirection operators (as indicated would happen in a message appended to the PR a week ago, which received no opposition - no feedback). Some rewriting of the section on redirects (including how the word expansion of the "file" works) to make this simpler & more accurate. To generate a diff of this commit: cvs rdiff -u -r1.221 -r1.222 src/bin/sh/sh.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/sh.1 diff -u src/bin/sh/sh.1:1.221 src/bin/sh/sh.1:1.222 --- src/bin/sh/sh.1:1.221 Mon Apr 15 20:35:25 2019 +++ src/bin/sh/sh.1 Mon Apr 22 04:04:35 2019 @@ -1,4 +1,4 @@ -.\" $NetBSD: sh.1,v 1.221 2019/04/15 20:35:25 uwe Exp $ +.\" $NetBSD: sh.1,v 1.222 2019/04/22 04:04:35 kre Exp $ .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" @@ -907,17 +907,42 @@ The overall format used for redirection where .Va redir-op is one of the redirection operators mentioned previously. -The following is a list of the possible redirections. +A list of the possible redirections, and their meanings, follows. +.Pp The .Op Ar n is an optional number, as in .Sq Li 3 (not -.Li [3] ) , +.Sq Li [3] ) , that refers to a file descriptor. -If present it must occur immediately before the redirection +If present it must occur unquoted, immediately before the redirection operator, with no intervening white space, and becomes a part of that operator. +If file descriptor +.Ar n +was open prior to the redirection, its previous use is closed. +.Pp +All redirections have a single word +.Ar file +argument following the operator +(white space is allowed between the redirection operator and +.Ar file ) , +though it is sometimes expressed as +.Ar n2 . +That argument is expanded +(see +.Sx "Word Expansions" +below) using tilde expansion, parameter expansion, +arithmetic expansion, command substitution and quote removal +to produce the path name (or file descriptor) to be used. +No field splitting or pathname expansion takes place. +In the list below, where the +.Ar file +is given as +.Ar n2 +the result of the expansions must be a number which +refers to a suitable open file descriptor. .Bl -tag -width aaabsfiles -offset indent .It Oo Ar n Oc Ns Ic > Ar file Redirect standard output (or @@ -938,22 +963,32 @@ Redirect standard input (or .Ar n ) from .Ar file . -.It Oo Ar n1 Oc Ns Ic <& Ns Ar n2 -Duplicate standard input (or +.It Oo Ar n1 Oc Ns Ic <& Ar n2 +Redirect standard input (or .Ar n1 ) -from file descriptor +from a duplicate of file descriptor .Ar n2 . -.Ar n2 -is expanded if not a digit string, the result must be a number. -.It Oo Ar n Oc Ns Ic <&- +.It Oo Ar n Oc Ns Ic <& \(mi Close standard input (or .Ar n ) . -.It Oo Ar n1 Oc Ns Ic >& Ns Ar n2 -Duplicate standard output (or +Note that the +.Sq \&\(mi +is minus sign (or hyphen) given literally or resulting +from the expansion of +.Ar file +(or +.Ar n2 ) +for this format. +When given literally there is usually no space between +the redirection operator and the +.Sq \&\(mi , +though that is just a convention. +.It Oo Ar n1 Oc Ns Ic >& Ar n2 +Redirect standard output (or .Ar n1 ) -to +to be a duplicate of .Ar n2 . -.It Oo Ar n Oc Ns Ic >&- +.It Oo Ar n Oc Ns Ic >& \(mi Close standard output (or .Ar n ) . .It Oo Ar n Oc Ns Ic <> Ar file
CVS commit: src/bin/sh
Module Name:src Committed By: uwe Date: Mon Apr 15 20:35:25 UTC 2019 Modified Files: src/bin/sh: sh.1 Log Message: -compact must come last To generate a diff of this commit: cvs rdiff -u -r1.220 -r1.221 src/bin/sh/sh.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/sh.1 diff -u src/bin/sh/sh.1:1.220 src/bin/sh/sh.1:1.221 --- src/bin/sh/sh.1:1.220 Thu Feb 14 11:15:24 2019 +++ src/bin/sh/sh.1 Mon Apr 15 20:35:25 2019 @@ -1,4 +1,4 @@ -.\" $NetBSD: sh.1,v 1.220 2019/02/14 11:15:24 kre Exp $ +.\" $NetBSD: sh.1,v 1.221 2019/04/15 20:35:25 uwe Exp $ .\" Copyright (c) 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" @@ -4110,7 +4110,7 @@ is processed and used. .It Ev EUSER Set to the login name of the effective user id running the shell, as returned by -.Bd -compact -literal -offset indent +.Bd -literal -offset indent -compact getpwuid(geteuid())->pw_name .Ed .Po
CVS commit: src/bin/sh
Module Name:src Committed By: kre Date: Tue Mar 26 13:32:26 UTC 2019 Modified Files: src/bin/sh: jobs.c Log Message: Fix a logic botch that prevented "wait -n" (with no pid args) from finding a job that had previously terminated. Now in that case JOBWANTED is set on all jobs (since any will do) which then simplifies a later test which no longer needs to special case "wait -n". Further, we always look to see if any wanted job has already terminated, even if there are still running jobs we can wait upon - if anything is already ready, that's where we start harvesting (and finish, if -n is specified). To generate a diff of this commit: cvs rdiff -u -r1.105 -r1.106 src/bin/sh/jobs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sh/jobs.c diff -u src/bin/sh/jobs.c:1.105 src/bin/sh/jobs.c:1.106 --- src/bin/sh/jobs.c:1.105 Sat Feb 9 09:31:33 2019 +++ src/bin/sh/jobs.c Tue Mar 26 13:32:26 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: jobs.c,v 1.105 2019/02/09 09:31:33 kre Exp $ */ +/* $NetBSD: jobs.c,v 1.106 2019/03/26 13:32:26 kre Exp $ */ /*- * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)jobs.c 8.5 (Berkeley) 5/4/95"; #else -__RCSID("$NetBSD: jobs.c,v 1.105 2019/02/09 09:31:33 kre Exp $"); +__RCSID("$NetBSD: jobs.c,v 1.106 2019/03/26 13:32:26 kre Exp $"); #endif #endif /* not lint */ @@ -710,9 +710,15 @@ waitcmd(int argc, char **argv) return (any || *argptr) ? 127 : 0; } - /* clear stray flags left from previous waitcmd */ + /* + * clear stray flags left from previous waitcmd + * or set them instead if anything will do ("wait -n") + */ for (jp = jobtab, i = njobs ; --i >= 0 ; jp++) { - jp->flags &= ~JOBWANTED; + if (any && *argptr == NULL) + jp->flags |= JOBWANTED; + else + jp->flags &= ~JOBWANTED; jp->ref = NULL; } @@ -784,20 +790,24 @@ waitcmd(int argc, char **argv) fpid = NULL; for (;;) { VTRACE(DBG_WAIT, ("wait waiting (%d remain): ", found)); + job = NULL; for (jp = jobtab, i = njobs; --i >= 0; jp++) { if (jp->used && jp->flags & JOBWANTED && - jp->state == JOBDONE) + jp->state == JOBDONE) { +job = jp; break; + } if (jp->used && jp->state == JOBRUNNING) -break; +job = jp; } - if (i < 0) { + if (i < 0 && job == NULL) { CTRACE(DBG_WAIT, ("nothing running (ret: %d) fpid %s\n", retval, fpid ? fpid : "unset")); if (pid && fpid) setvar(pid, fpid, 0); return retval; } + jp = job; VTRACE(DBG_WAIT, ("found @%d/%d state: %d\n", njobs-i, njobs, jp->state)); @@ -819,7 +829,7 @@ waitcmd(int argc, char **argv) } else job = jp; /* we want this, and it is done */ - if (job->flags & JOBWANTED || (*argptr == 0 && any)) { + if (job->flags & JOBWANTED) { int rv; job->flags &= ~JOBWANTED; /* got it */
CVS commit: src/bin/dd
Module Name:src Committed By: mlelstv Date: Sat Mar 23 09:33:16 UTC 2019 Modified Files: src/bin/dd: dd.c Log Message: When buffers are at least page sized, explicitely request page alignment. To generate a diff of this commit: cvs rdiff -u -r1.51 -r1.52 src/bin/dd/dd.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/dd/dd.c diff -u src/bin/dd/dd.c:1.51 src/bin/dd/dd.c:1.52 --- src/bin/dd/dd.c:1.51 Mon Sep 5 01:00:07 2016 +++ src/bin/dd/dd.c Sat Mar 23 09:33:16 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: dd.c,v 1.51 2016/09/05 01:00:07 sevan Exp $ */ +/* $NetBSD: dd.c,v 1.52 2019/03/23 09:33:16 mlelstv Exp $ */ /*- * Copyright (c) 1991, 1993, 1994 @@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1991, 19 #if 0 static char sccsid[] = "@(#)dd.c 8.5 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: dd.c,v 1.51 2016/09/05 01:00:07 sevan Exp $"); +__RCSID("$NetBSD: dd.c,v 1.52 2019/03/23 09:33:16 mlelstv Exp $"); #endif #endif /* not lint */ @@ -72,6 +72,7 @@ static void dd_in(void); static void getfdtype(IO *); static void redup_clean_fd(IO *); static void setup(void); +static void *buffer_alloc(size_t); IO in, out; /* input/output state */ STAT st; /* statistics */ @@ -150,6 +151,20 @@ main(int argc, char *argv[]) /* NOTREACHED */ } +static void * +buffer_alloc(size_t sz) +{ + size_t align = getpagesize(); + void *res; + + if (sz < align) + res = malloc(sz); + else if (posix_memalign(, align, sz) != 0) + res = NULL; + + return res; +} + static void setup(void) { @@ -233,14 +248,14 @@ setup(void) size_t dbsz = out.dbsz; if (!(ddflags & C_BS)) dbsz += in.dbsz - 1; - if ((in.db = malloc(dbsz)) == NULL) { + if ((in.db = buffer_alloc(dbsz)) == NULL) { err(EXIT_FAILURE, NULL); /* NOTREACHED */ } out.db = in.db; } else if ((in.db = - malloc((u_int)(MAX(in.dbsz, cbsz) + cbsz))) == NULL || - (out.db = malloc((u_int)(out.dbsz + cbsz))) == NULL) { + buffer_alloc((u_int)(MAX(in.dbsz, cbsz) + cbsz))) == NULL || + (out.db = buffer_alloc((u_int)(out.dbsz + cbsz))) == NULL) { err(EXIT_FAILURE, NULL); /* NOTREACHED */ }
CVS commit: src/bin/pax
Module Name:src Committed By: gutteridge Date: Wed Mar 20 03:13:39 UTC 2019 Modified Files: src/bin/pax: file_subs.c tar.c Log Message: pax: fix typos in comments in file_subs.c & tar.c Stamp out "greengrocers' apostrophes" in various places (arguably there are still more present, but style guides vary on that, and my energies spent corralling wayward punctuation marks could be spent elsewhere). To generate a diff of this commit: cvs rdiff -u -r1.63 -r1.64 src/bin/pax/file_subs.c cvs rdiff -u -r1.74 -r1.75 src/bin/pax/tar.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/pax/file_subs.c diff -u src/bin/pax/file_subs.c:1.63 src/bin/pax/file_subs.c:1.64 --- src/bin/pax/file_subs.c:1.63 Mon Jul 29 17:46:36 2013 +++ src/bin/pax/file_subs.c Wed Mar 20 03:13:39 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: file_subs.c,v 1.63 2013/07/29 17:46:36 christos Exp $ */ +/* $NetBSD: file_subs.c,v 1.64 2019/03/20 03:13:39 gutteridge Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)file_subs.c 8.1 (Berkeley) 5/31/93"; #else -__RCSID("$NetBSD: file_subs.c,v 1.63 2013/07/29 17:46:36 christos Exp $"); +__RCSID("$NetBSD: file_subs.c,v 1.64 2019/03/20 03:13:39 gutteridge Exp $"); #endif #endif /* not lint */ @@ -895,7 +895,7 @@ set_chflags(char *fnm, u_int32_t flags) * actual storage is quite small (the files are sparse). The problem is * the holes read as all zeros so are probably stored on the archive that * way (there is no way to determine if the file block is really a hole, - * we only know that a file block of all zero's can be a hole). + * we only know that a file block of all zeros can be a hole). * At this writing, no major archive format knows how to archive files * with holes. However, on extraction (or during copy, -rw) we have to * deal with these files. Without detecting the holes, the files can @@ -968,7 +968,7 @@ file_write(int fd, char *str, int cnt, i if (*isempt) { /* * have not written to this block yet, so we keep - * looking for zero's + * looking for zeros */ pt = st; end = st + wcnt; Index: src/bin/pax/tar.c diff -u src/bin/pax/tar.c:1.74 src/bin/pax/tar.c:1.75 --- src/bin/pax/tar.c:1.74 Fri Nov 30 00:53:11 2018 +++ src/bin/pax/tar.c Wed Mar 20 03:13:39 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: tar.c,v 1.74 2018/11/30 00:53:11 christos Exp $ */ +/* $NetBSD: tar.c,v 1.75 2019/03/20 03:13:39 gutteridge Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)tar.c 8.2 (Berkeley) 4/18/94"; #else -__RCSID("$NetBSD: tar.c,v 1.74 2018/11/30 00:53:11 christos Exp $"); +__RCSID("$NetBSD: tar.c,v 1.75 2019/03/20 03:13:39 gutteridge Exp $"); #endif #endif /* not lint */ @@ -351,7 +351,7 @@ tar_chksm(char *blk, int len) * checksum field as the sum of 8 blanks (which is pre-computed as * BLNKSUM). * ASSUMED: len is greater than CHK_OFFSET. (len is where our 0 padding - * starts, no point in summing zero's) + * starts, no point in summing zeros) */ pt += CHK_LEN; stop = blk + len; @@ -368,7 +368,7 @@ tar_chksm(char *blk, int len) * tar_id() * determine if a block given to us is a valid tar header (and not a USTAR * header). We have to be on the lookout for those pesky blocks of all - * zero's. + * zeros. * Return: * 0 if a tar header, -1 otherwise */ @@ -386,7 +386,7 @@ tar_id(char *blk, int size) uhd = (HD_USTAR *)blk; /* - * check for block of zero's first, a simple and fast test, then make + * check for block of zeros first, a simple and fast test, then make * sure this is not a ustar header by looking for the ustar magic * cookie. We should use TMAGLEN, but some USTAR archive programs are * wrong and create archives missing the \0. Last we check the @@ -769,7 +769,7 @@ ustar_stwr(void) /* * ustar_id() * determine if a block given to us is a valid ustar header. We have to - * be on the lookout for those pesky blocks of all zero's + * be on the lookout for those pesky blocks of all zeros * Return: * 0 if a ustar header, -1 otherwise */ @@ -784,7 +784,7 @@ ustar_id(char *blk, int size) hd = (HD_USTAR *)blk; /* - * check for block of zero's first, a simple and fast test then check + * check for block of zeros first, a simple and fast test then check * ustar magic cookie. We should use TMAGLEN, but some USTAR archive * programs are fouled up and create archives missing the \0. Last we * check the checksum. If ok we have to assume it is a valid header. @@ -1379,7 +1379,7 @@ tar_gnutar_exclude_one(const char *line, } /* - * deal with GNU tar -X/--exclude-from & --exclude switchs. basically, + * deal with GNU tar -X/--exclude-from & --exclude switches. basically, * we go through each line of the file, building a string from the "glob" * lines in the file into RE lines, of
CVS commit: src/bin/pax
Module Name:src Committed By: gutteridge Date: Wed Mar 20 02:50:50 UTC 2019 Modified Files: src/bin/pax: pat_rep.c Log Message: pax: minor adjustments to comments in pat_rep.c Amend several comments to match present reality (the functionality was added back in 2007). To generate a diff of this commit: cvs rdiff -u -r1.30 -r1.31 src/bin/pax/pat_rep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/pax/pat_rep.c diff -u src/bin/pax/pat_rep.c:1.30 src/bin/pax/pat_rep.c:1.31 --- src/bin/pax/pat_rep.c:1.30 Wed Jun 13 15:14:40 2018 +++ src/bin/pax/pat_rep.c Wed Mar 20 02:50:50 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: pat_rep.c,v 1.30 2018/06/13 15:14:40 christos Exp $ */ +/* $NetBSD: pat_rep.c,v 1.31 2019/03/20 02:50:50 gutteridge Exp $ */ /*- * Copyright (c) 1992 Keith Muller. @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)pat_rep.c 8.2 (Berkeley) 4/18/94"; #else -__RCSID("$NetBSD: pat_rep.c,v 1.30 2018/06/13 15:14:40 christos Exp $"); +__RCSID("$NetBSD: pat_rep.c,v 1.31 2019/03/20 02:50:50 gutteridge Exp $"); #endif #endif /* not lint */ @@ -85,12 +85,13 @@ static int resub(regex_t *, regmatch_t * * parses the -s replacement string; compiles the regular expression * and stores the compiled value and its replacement string together in * replacement string list. Input to this function is of the form: - * /old/new/pg + * /old/new/gps * The first char in the string specifies the delimiter used by this * replacement string. "Old" is a regular expression in "ed" format which * is compiled by regcomp() and is applied to filenames. "new" is the - * substitution string; p and g are options flags for printing and global - * replacement (over the single filename) + * substitution string; g, p, and s are options flags for global + * replacement (over the single filename), printing, and preventing + * substitutions on symbolic link destinations. * Return: * 0 if a proper replacement string and regular expression was added to * the list of replacement patterns; -1 otherwise. @@ -895,7 +896,7 @@ fix_path( char *or_name, int *or_len, ch * namelen the size of the name buffer. * nlen is the length of this name (and is modified to hold the length of * the final string). - * prnt is a flag that says whether to print the final result. + * flags contains various options to control behavior. * Return: * 0 if substitution was successful, 1 if we are to skip the file (the name * ended up empty)
CVS commit: src/bin/pax
Module Name:src Committed By: wiz Date: Tue Mar 19 10:14:46 UTC 2019 Modified Files: src/bin/pax: tar.1 Log Message: Whitespace nits. To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/bin/pax/tar.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/pax/tar.1 diff -u src/bin/pax/tar.1:1.38 src/bin/pax/tar.1:1.39 --- src/bin/pax/tar.1:1.38 Tue Mar 19 00:36:14 2019 +++ src/bin/pax/tar.1 Tue Mar 19 10:14:46 2019 @@ -1,4 +1,4 @@ -.\" $NetBSD: tar.1,v 1.38 2019/03/19 00:36:14 gutteridge Exp $ +.\" $NetBSD: tar.1,v 1.39 2019/03/19 10:14:46 wiz Exp $ .\" .\" Copyright (c) 1996 SigmaSoft, Th. Lockert .\" All rights reserved. @@ -107,10 +107,10 @@ then the archive will be processed using .It Fl h , Fl Fl dereference Follow symbolic links as if they were normal files or directories. -.It Fl J, Fl Fl xz +.It Fl J , Fl Fl xz Compress/decompress archive using .Xr xz 1 . -.It Fl j, Fl Fl bzip2, Fl Fl bunzip2 +.It Fl j , Fl Fl bzip2 , Fl Fl bunzip2 Use .Xr bzip2 1 for compression of the archive.
CVS commit: src/bin/pax
Module Name:src Committed By: gutteridge Date: Tue Mar 19 00:36:14 UTC 2019 Modified Files: src/bin/pax: pax.1 tar.1 Log Message: pax.1 & tar.1: add a minor clarification about "-s" As a somewhat pedantic clarification, "-s" does not accept backslashes as delimiters. (While here, also make the macro use of an expression shared between pax.1 and tar.1 consistent.) To generate a diff of this commit: cvs rdiff -u -r1.70 -r1.71 src/bin/pax/pax.1 cvs rdiff -u -r1.37 -r1.38 src/bin/pax/tar.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/pax/pax.1 diff -u src/bin/pax/pax.1:1.70 src/bin/pax/pax.1:1.71 --- src/bin/pax/pax.1:1.70 Tue Mar 19 00:12:08 2019 +++ src/bin/pax/pax.1 Tue Mar 19 00:36:14 2019 @@ -1,4 +1,4 @@ -.\"$NetBSD: pax.1,v 1.70 2019/03/19 00:12:08 gutteridge Exp $ +.\"$NetBSD: pax.1,v 1.71 2019/03/19 00:36:14 gutteridge Exp $ .\" .\" Copyright (c) 1992 Keith Muller. .\" Copyright (c) 1992, 1993 @@ -585,7 +585,8 @@ The string may also contain .Aq Dv newline characters. -Any non-null character can be used as a delimiter (/ is shown here). +Any non-null character except a backslash (\\) can be used as a delimiter +(/ is shown here). Multiple .Fl s expressions can be specified. Index: src/bin/pax/tar.1 diff -u src/bin/pax/tar.1:1.37 src/bin/pax/tar.1:1.38 --- src/bin/pax/tar.1:1.37 Mon Jul 3 21:33:23 2017 +++ src/bin/pax/tar.1 Tue Mar 19 00:36:14 2019 @@ -1,4 +1,4 @@ -.\" $NetBSD: tar.1,v 1.37 2017/07/03 21:33:23 wiz Exp $ +.\" $NetBSD: tar.1,v 1.38 2019/03/19 00:36:14 gutteridge Exp $ .\" .\" Copyright (c) 1996 SigmaSoft, Th. Lockert .\" All rights reserved. @@ -25,7 +25,7 @@ .\" .\" OpenBSD: tar.1,v 1.28 2000/11/09 23:58:56 aaron Exp .\" -.Dd December 19, 2015 +.Dd March 19, 2019 .Dt TAR 1 .Os .Sh NAME @@ -177,7 +177,8 @@ The string may also contain .Aq Dv newline characters. -Any non-null character can be used as a delimiter (/ is shown here). +Any non-null character except a backslash (\\) can be used as a delimiter +(/ is shown here). Multiple .Fl s expressions can be specified. @@ -196,7 +197,7 @@ The optional trailing will cause the final result of a successful substitution to be written to .Dv standard error in the following format: -.Dl >> +.Dl Ao "original pathname" Ac >> Ao "new pathname" Ac File or archive member names that substitute to the empty string are not selected and will be skipped. The substitutions are applied by default to the destination hard and symbolic
CVS commit: src/bin/pax
Module Name:src Committed By: gutteridge Date: Tue Mar 19 00:12:08 UTC 2019 Modified Files: src/bin/pax: pax.1 Log Message: pax.1: document the "s" flag of the "s" option Note the "s" option has an "s" flag that "prevents substitutions from being performed on symbolic link destinations". Carry over r. 1.25 from christos@ and part of r. 1.26 from wiz@ from tar.1, since this functionality is available in pax as well as tar. To generate a diff of this commit: cvs rdiff -u -r1.69 -r1.70 src/bin/pax/pax.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/pax/pax.1 diff -u src/bin/pax/pax.1:1.69 src/bin/pax/pax.1:1.70 --- src/bin/pax/pax.1:1.69 Mon Jul 3 21:33:23 2017 +++ src/bin/pax/pax.1 Tue Mar 19 00:12:08 2019 @@ -1,4 +1,4 @@ -.\"$NetBSD: pax.1,v 1.69 2017/07/03 21:33:23 wiz Exp $ +.\"$NetBSD: pax.1,v 1.70 2019/03/19 00:12:08 gutteridge Exp $ .\" .\" Copyright (c) 1992 Keith Muller. .\" Copyright (c) 1992, 1993 @@ -33,7 +33,7 @@ .\" .\" @(#)pax.1 8.4 (Berkeley) 4/18/94 .\" -.Dd August 12, 2016 +.Dd March 19, 2019 .Dt PAX 1 .Os .Sh NAME @@ -572,7 +572,7 @@ using the syntax of the .Xr ed 1 utility regular expressions. The format of these regular expressions are: -.Dl /old/new/[gp] +.Dl /old/new/[gps] As in .Xr ed 1 , .Cm old @@ -607,6 +607,11 @@ in the following format: .Dl Ao "original pathname" Ac >> Ao "new pathname" Ac File or archive member names that substitute to the empty string are not selected and will be skipped. +The substitutions are applied by default to the destination hard and symbolic +links. +The optional trailing +.Cm s +prevents the substitutions from being performed on symbolic link destinations. .It Fl t Reset the access times of any file or directory read or accessed by .Nm
CVS commit: src/bin/sleep
Module Name:src Committed By: kre Date: Sun Mar 10 15:18:45 UTC 2019 Modified Files: src/bin/sleep: sleep.c Log Message: Deal with overflow when the sleep duration given is a simple integer (previously it was just clamped at the max possible value). This would have caused sleep 1000 (or anything bigger) to have only actually slept for 9223372036854775807 secs. Someone would have noticed that happen, one day, in some other universe. This is now an error, as it was previously if this had been entered as sleep 1e19 Also detect an attempt to sleep for so long that a time_t will no longer be able to represent the current time when the sleep is done. Undo the attempts to work around a broken kernel nanosleep() implementation (by only ever issuing shortish sleep requests, and looping). That code was broken (idiot botch of mine) though you would have had to wait a month to observe it happen. I was going to just fix it, but sanity prevailed, and the kernel got fixed instead. That allows this to be much simplified, only looping as needed to handle dealing with SIGINFO. Switch to using clock_nanosleep() to implement the delay, as while our nanosleep() uses CLOCK_MONOTONIC the standards say it should use CLOCK_REALTIME, and if that we ever changed that, the old way would alter "sleep 5" from "sleep for 5 seconds" to "sleep until now + 5 secs", which is subtly different. Always use %g format to print the original sleep duration in reports of how much time remains - this works best for both long and short durations. A couple of other minor (frill) mods to the SIGINFO report message as well. To generate a diff of this commit: cvs rdiff -u -r1.29 -r1.30 src/bin/sleep/sleep.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/bin/sleep/sleep.c diff -u src/bin/sleep/sleep.c:1.29 src/bin/sleep/sleep.c:1.30 --- src/bin/sleep/sleep.c:1.29 Sun Jan 27 02:00:45 2019 +++ src/bin/sleep/sleep.c Sun Mar 10 15:18:45 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: sleep.c,v 1.29 2019/01/27 02:00:45 christos Exp $ */ +/* $NetBSD: sleep.c,v 1.30 2019/03/10 15:18:45 kre Exp $ */ /* * Copyright (c) 1988, 1993, 1994 @@ -39,17 +39,19 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19 #if 0 static char sccsid[] = "@(#)sleep.c 8.3 (Berkeley) 4/2/94"; #else -__RCSID("$NetBSD: sleep.c,v 1.29 2019/01/27 02:00:45 christos Exp $"); +__RCSID("$NetBSD: sleep.c,v 1.30 2019/03/10 15:18:45 kre Exp $"); #endif #endif /* not lint */ #include #include +#include #include #include #include #include #include +#include #include #include @@ -73,9 +75,10 @@ main(int argc, char *argv[]) const char *msg; double fval, ival, val; struct timespec ntime; + struct timespec endtime; + struct timespec now; time_t original; int ch, fracflag; - unsigned delay; setprogname(argv[0]); (void)setlocale(LC_ALL, ""); @@ -145,9 +148,15 @@ main(int argc, char *argv[]) if (ntime.tv_sec == 0 && ntime.tv_nsec == 0) return EXIT_SUCCESS; /* was 0.0 or underflowed */ } else { + errno = 0; ntime.tv_sec = strtol(arg, , 10); if (ntime.tv_sec < 0 || temp == arg || *temp != '\0') usage(); + if (errno == ERANGE) + errx(EXIT_FAILURE, "Requested delay (%s) out of range", + arg); + else if (errno != 0) + err(EXIT_FAILURE, "Requested delay (%s)", arg); if (ntime.tv_sec == 0) return EXIT_SUCCESS; @@ -155,40 +164,45 @@ main(int argc, char *argv[]) } original = ntime.tv_sec; - if (ntime.tv_nsec != 0) - msg = " and a bit"; - else + if (original < 86400) { + if (ntime.tv_nsec > 10 * 2 / 3) { + original++; + msg = " less a bit"; + } else if (ntime.tv_nsec != 0) + msg = " and a bit"; + else + msg = ""; + } else msg = ""; + if (clock_gettime(CLOCK_MONOTONIC, ) != 0) + err(EXIT_FAILURE, "clock_gettime"); + timespecadd(, , ); + + if (endtime.tv_sec < now.tv_sec || (endtime.tv_sec == now.tv_sec && + endtime.tv_nsec <= now.tv_nsec)) + errx(EXIT_FAILURE, "cannot sleep beyond the end of time"); + signal(SIGINFO, report_request); + for (;;) { + int e; + + if ((e = clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, + , NULL)) == 0) + return EXIT_SUCCESS; - if (ntime.tv_sec <= 1) { /* arbitrary */ - while (nanosleep(, ) != 0) { - if (report_requested) { -report(ntime.tv_sec, original, msg); -report_requested = 0; - } else -err(EXIT_FAILURE, "nanosleep failed"); + if (!report_requested || e != EINTR) { + errno = e; + err(EXIT_FAILURE, "clock_nanotime"); } - } else while (ntime.tv_sec > 0) { - delay = (unsigned int)ntime.tv_sec; - if ((time_t)delay != ntime.tv_sec || delay > 30 * 86400) - delay = 30 * 86400; + report_requested = 0; + if (clock_gettime(CLOCK_MONOTONIC, ) != 0) /* Huh? */ + continue; - ntime.tv_sec -= delay; - delay = sleep(delay); - ntime.tv_sec += delay; - - if (delay != 0 &&