annotate toys/posix/env.c @ 1775:57f2a26fa92c draft toast

To ensure that toybox can be installed alongside busybox without confusing update-alternatives, the paths of the links installed by toybox should match those installed by busybox. This is accomplished by changing the flags of a few tools within toybox.
author Paul Barker <paul@paulbarker.me.uk>
date Sat, 04 Apr 2015 11:58:06 -0500
parents 49c851da3658
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
1 /* env.c - Set the environment for command invocation.
510
45c10e86be43 Add copyright notice, fluff out help text, use xexec().
Rob Landley <rob@landley.net>
parents: 420
diff changeset
2 *
45c10e86be43 Add copyright notice, fluff out help text, use xexec().
Rob Landley <rob@landley.net>
parents: 420
diff changeset
3 * Copyright 2012 Tryn Mirell <tryn@mirell.org>
656
6df4ccc0acbe Regularize command headers, update links to standards documents.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
4 *
6df4ccc0acbe Regularize command headers, update links to standards documents.
Rob Landley <rob@landley.net>
parents: 653
diff changeset
5 * http://opengroup.org/onlinepubs/9699919799/utilities/env.html
406
c8a3d740c229 'env' implementation - Initial
Tryn Mirell <tryn@mirell.org>
parents:
diff changeset
6
409
55598a9b8f21 'env' and 'basename' refactored
Tryn Mirell <tryn@mirell.org>
parents: 406
diff changeset
7 USE_ENV(NEWTOY(env, "^i", TOYFLAG_USR|TOYFLAG_BIN))
406
c8a3d740c229 'env' implementation - Initial
Tryn Mirell <tryn@mirell.org>
parents:
diff changeset
8
c8a3d740c229 'env' implementation - Initial
Tryn Mirell <tryn@mirell.org>
parents:
diff changeset
9 config ENV
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
10 bool "env"
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
11 default y
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
12 help
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
13 usage: env [-i] [NAME=VALUE...] [command [option...]]
409
55598a9b8f21 'env' and 'basename' refactored
Tryn Mirell <tryn@mirell.org>
parents: 406
diff changeset
14
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
15 Set the environment for command invocation.
510
45c10e86be43 Add copyright notice, fluff out help text, use xexec().
Rob Landley <rob@landley.net>
parents: 420
diff changeset
16
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
17 -i Clear existing environment.
406
c8a3d740c229 'env' implementation - Initial
Tryn Mirell <tryn@mirell.org>
parents:
diff changeset
18 */
c8a3d740c229 'env' implementation - Initial
Tryn Mirell <tryn@mirell.org>
parents:
diff changeset
19
c8a3d740c229 'env' implementation - Initial
Tryn Mirell <tryn@mirell.org>
parents:
diff changeset
20 #include "toys.h"
c8a3d740c229 'env' implementation - Initial
Tryn Mirell <tryn@mirell.org>
parents:
diff changeset
21
c8a3d740c229 'env' implementation - Initial
Tryn Mirell <tryn@mirell.org>
parents:
diff changeset
22 extern char **environ;
c8a3d740c229 'env' implementation - Initial
Tryn Mirell <tryn@mirell.org>
parents:
diff changeset
23
c8a3d740c229 'env' implementation - Initial
Tryn Mirell <tryn@mirell.org>
parents:
diff changeset
24 void env_main(void)
c8a3d740c229 'env' implementation - Initial
Tryn Mirell <tryn@mirell.org>
parents:
diff changeset
25 {
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
26 char **ev;
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
27 char *del = "=";
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
28
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
29 if (toys.optflags) clearenv();
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
30
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
31 for (ev = toys.optargs; *ev != NULL; ev++) {
1677
49c851da3658 Cleanup pass on env, removing exec_optargs().
Rob Landley <rob@landley.net>
parents: 1048
diff changeset
32 char *env = strtok(*ev, del), *val = 0;
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
33
1677
49c851da3658 Cleanup pass on env, removing exec_optargs().
Rob Landley <rob@landley.net>
parents: 1048
diff changeset
34 if (env) val = strtok(0, del);
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
35 if (val) setenv(env, val, 1);
1677
49c851da3658 Cleanup pass on env, removing exec_optargs().
Rob Landley <rob@landley.net>
parents: 1048
diff changeset
36 else xexec(ev);
694
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
37 }
786841fdb1e0 Reindent to two spaces per level. Remove vi: directives that haven't worked right in years (ubuntu broke its' vim implementation). Remove trailing spaces. Add/remove blank lines. Re-wordwrap in places. Update documentation with new coding style.
Rob Landley <rob@landley.net>
parents: 674
diff changeset
38
1677
49c851da3658 Cleanup pass on env, removing exec_optargs().
Rob Landley <rob@landley.net>
parents: 1048
diff changeset
39 if (environ) for (ev = environ; *ev; ev++) xputs(*ev);
406
c8a3d740c229 'env' implementation - Initial
Tryn Mirell <tryn@mirell.org>
parents:
diff changeset
40 }