Index: usr.bin/diff/diff.c =================================================================== --- usr.bin/diff/diff.c +++ usr.bin/diff/diff.c @@ -322,7 +322,7 @@ if (S_ISDIR(stb2.st_mode)) { argv[1] = splice(argv[1], argv[0]); if (stat(argv[1], &stb2) < 0) - err(2, "%s", argv[1]); + warn(2, "%s", argv[1]); } print_status(diffreg(argv[0], argv[1], dflags, 1), argv[0], argv[1], ""); Index: usr.bin/env/env.1 =================================================================== --- usr.bin/env/env.1 +++ usr.bin/env/env.1 @@ -31,7 +31,7 @@ .\" From FreeBSD: src/usr.bin/printenv/printenv.1,v 1.17 2002/11/26 17:33:35 ru Exp .\" $FreeBSD$ .\" -.Dd April 17, 2008 +.Dd November 3, 2019 .Dt ENV 1 .Os .Sh NAME @@ -39,7 +39,7 @@ .Nd set environment and execute command, or print environment .Sh SYNOPSIS .Nm -.Op Fl iv +.Op Fl 0iv .Op Fl P Ar altpath .Op Fl S Ar string .Op Fl u Ar name @@ -64,6 +64,8 @@ .Pp The options are as follows: .Bl -tag -width indent +.It Fl 0 +End each output line with NUL, not newline. .It Fl i Execute the .Ar utility @@ -132,6 +134,11 @@ .Nm prints out the names and values of the variables in the environment, with one name/value pair per line. +If +.Fl 0 +is supplied, +.Ar utility +is ignored and the variables are separated by NUL instead of lines. .\" .Ss Details of Fl S \&Ss (split-string) processing The processing of the Index: usr.bin/env/env.c =================================================================== --- usr.bin/env/env.c +++ usr.bin/env/env.c @@ -62,19 +62,23 @@ int main(int argc, char **argv) { - char *altpath, **ep, *p, **parg; + char *altpath, **ep, *p, **parg, term; char *cleanenv[1]; int ch, want_clear; int rtrn; altpath = NULL; want_clear = 0; - while ((ch = getopt(argc, argv, "-iP:S:u:v")) != -1) + term = '\n'; + while ((ch = getopt(argc, argv, "-0iP:S:u:v")) != -1) switch(ch) { case '-': case 'i': want_clear = 1; break; + case '0': + term = '\0'; + break; case 'P': altpath = strdup(optarg); break; @@ -118,21 +122,25 @@ err(EXIT_FAILURE, "setenv %s", *argv); } if (*argv) { - if (altpath) - search_paths(altpath, argv); - if (env_verbosity) { - fprintf(stderr, "#env executing:\t%s\n", *argv); - for (parg = argv, argc = 0; *parg; parg++, argc++) - fprintf(stderr, "#env arg[%d]=\t'%s'\n", - argc, *parg); - if (env_verbosity > 1) - sleep(1); + if (term == '\0') + fprintf(stderr, "Command ignored with -0.\n"); + else { + if (altpath) + search_paths(altpath, argv); + if (env_verbosity) { + fprintf(stderr, "#env executing:\t%s\n", *argv); + for (parg = argv, argc = 0; *parg; parg++, argc++) + fprintf(stderr, "#env arg[%d]=\t'%s'\n", + argc, *parg); + if (env_verbosity > 1) + sleep(1); + } + execvp(*argv, argv); + err(errno == ENOENT ? 127 : 126, "%s", *argv); } - execvp(*argv, argv); - err(errno == ENOENT ? 127 : 126, "%s", *argv); } for (ep = environ; *ep; ep++) - (void)printf("%s\n", *ep); + (void)printf("%s%c", *ep, term); exit(0); } @@ -140,7 +148,7 @@ usage(void) { (void)fprintf(stderr, - "usage: env [-iv] [-P utilpath] [-S string] [-u name]\n" + "usage: env [-0iv] [-P utilpath] [-S string] [-u name]\n" " [name=value ...] [utility [argument ...]]\n"); exit(1); }