Commit Graph

21 Commits

Author SHA1 Message Date
Joel Dahl
da52b4caaf Remove the advertising clause from UCB copyrighted files in usr.bin. This
is in accordance with the information provided at
ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change

Also add $FreeBSD$ to a few files to keep svn happy.

Discussed with:	imp, rwatson
2010-12-11 08:32:16 +00:00
Garance A Drosehn
a414225db1 Add the '-u name' option to the env command, which will completely unset
the given variable name (removing it from the environment, instead of
just setting it to a null value).

PR:		bin/65649
MFC after:	2 weeks
2008-04-17 23:17:09 +00:00
Sean Farley
2966d28c32 Significantly reduce the memory leak as noted in BUGS section for
setenv(3) by tracking the size of the memory allocated instead of using
strlen() on the current value.

Convert all calls to POSIX from historic BSD API:
 - unsetenv returns an int.
 - putenv takes a char * instead of const char *.
 - putenv no longer makes a copy of the input string.
 - errno is set appropriately for POSIX.  Exceptions involve bad environ
   variable and internal initialization code.  These both set errno to
   EFAULT.

Several patches to base utilities to handle the POSIX changes from
Andrey Chernov's previous commit.  A few I re-wrote to use setenv()
instead of putenv().

New regression module for tools/regression/environ to test these
functions.  It also can be used to test the performance.

Bump __FreeBSD_version to 700050 due to API change.

PR:		kern/99826
Approved by:	wes
Approved by:	re (kensmith)
2007-07-04 00:00:41 +00:00
Andrey A. Chernov
ba174a5e38 Back out all POSIXified *env() changes.
Not because I admit they are technically wrong and not because of bug
reports (I receive nothing). But because I surprisingly meets so
strong opposition and resistance so lost any desire to continue that.

Anyone who interested in POSIX can dig out what changes and how
through cvs diffs.
2007-05-01 16:02:44 +00:00
Andrey A. Chernov
ed4bcacfde env calls setenv("name=value", "value", 1); which violates POSIX:
"The setenv( ) function shall fail if:
[EINVAL] The name argument is a null pointer, points to an empty string,
or points to a string containing an '=' character."
The fix (like all others in this subject) is backward-compatible.
2007-04-30 19:25:00 +00:00
Garance A Drosehn
2f739d3c1a Undo r1.14 to env.c. While it is unusual for environment variables to
start with a '/', they are more supported (by POSIX and SUSv3) than
filenames which have an '=' in them.

Noticed by:	tjr
Approved by:	re (blanket `env')
2005-06-21 19:38:26 +00:00
Garance A Drosehn
8fbe7ebf7d Add the '-S' and '-P' options. The '-S' option can be used to split
apart a string, and supports some text substitutions.  This can be
used to provide all the flexibility (and more!) that was lost by recent
changes to how the kernel parses #!-lines in shell scripts.

The '-P' option provides a way to specify an alternate set of directories
to use when searching for the 'utility' program to run.  This way you can
be sure what directories are used for that search, without changing the
value of PATH that the user has set.  Note that on FreeBSD 6.0, this
option is worthless unless the '-S' option is also used.

Approved by:	re (blanket `env')
2005-06-20 03:43:25 +00:00
Garance A Drosehn
6dcd6cac03 If the `utility' specified starts with a '/' character, then execute it
without checking it for an equals-sign.  If it starts with a slash, then
it cannot be a request to set the value of a valid environment variable.

Approved by:	re (blanket `env')
2005-06-20 03:14:29 +00:00
Garance A Drosehn
212274c3b6 Move the code that clears the environment when `-i' is specified, so it that
it does not happen until all single-letter options are processed.  This will
be important for the -S option, which will be coming soon.

Approved by:	re (blanket `env')
2005-06-20 03:09:49 +00:00
Garance A Drosehn
f66e378b5e Add a '-v' option to `env', to make it easier to discover exactly what steps
it is doing, and what order it does them.  This will be much more useful as
more options are added.

Approved by:	re (blanket `env')
2005-06-20 03:06:54 +00:00
David Malone
f4ac32def2 ANSIify function definitions.
Add some constness to avoid some warnings.
Remove use register keyword.
Deal with missing/unneeded extern/prototypes.
Some minor type changes/casts to avoid warnings.

Reviewed by:	md5
2002-09-04 23:29:10 +00:00
Tim J. Robbins
6ec9d03768 Discourage use of env(1)'s "-" flag by moving its description to the
Compatibility section of the manual page.
2002-06-28 09:23:39 +00:00
Tim J. Robbins
7e949b63e4 Indicate that env(1) allows you to supply arguments to the utility it
executes in the usage() message and manual page. Use "utility" instead of
"command" in both places to emphasise that shell builtins etc. will not work,
and to be consistent with the terminology used by POSIX.

PR:		39210
Submitted by:	Danny J. Zerkel <dzerkel@columbus.rr.com>
MFC after:	1 week
2002-06-19 07:09:44 +00:00
Warner Losh
f1bb2cd2aa remove __P 2002-03-22 01:22:50 +00:00
Mike Barcroft
064692095c Leave the `copyright' variable exposed, since the main purpose of it
is to put a copyright in the object file.

Submitted by:	bde
2002-03-07 10:06:00 +00:00
Mike Barcroft
603460a71c Use new ID scheme.
Fix env(1)'s exit status to conform with SUSv3.

Submitted by:	Tim Robbins <tim@robbins.dropbear.id.au>
MFC after:	2 weeks
2002-02-21 02:17:57 +00:00
Sheldon Hearn
85ab7ba1e0 Add `-i'' option, which is the same as `-''. The -i option is the
recommended option in the manpage, but the - option remains for
backward compatibility and is documented as such.

PR:	13363
Reported by:	James Howard <howardjp@wam.umd.edu>
Reviewed by:	bde
1999-08-27 08:59:32 +00:00
Archie Cobbs
fa146c5335 Tweaks to allow compiling -Wall (mostly adding "const" to char rcsid[]). 1998-12-06 22:58:23 +00:00
Philippe Charnier
d98fe20585 Add usage(). 1997-06-30 06:51:20 +00:00
Warner Losh
1c8af87873 compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.
1997-03-29 04:34:07 +00:00
Rodney W. Grimes
9b50d90275 BSD 4.4 Lite Usr.bin Sources 1994-05-27 12:33:43 +00:00