Mercurial > hg > toybox
comparison toys/env.c @ 510:45c10e86be43
Add copyright notice, fluff out help text, use xexec().
author | Rob Landley <rob@landley.net> |
---|---|
date | Fri, 02 Mar 2012 20:18:02 -0600 |
parents | eda61bcf575a |
children |
comparison
equal
deleted
inserted
replaced
509:e7c742f78361 | 510:45c10e86be43 |
---|---|
1 /* vi: set sw=4 ts=4: | 1 /* vi: set sw=4 ts=4: |
2 * | |
3 * env.c - Set the environment for command invocation. | |
4 * | |
5 * Copyright 2012 Tryn Mirell <tryn@mirell.org> | |
2 * env.c | 6 * env.c |
3 | 7 |
4 USE_ENV(NEWTOY(env, "^i", TOYFLAG_USR|TOYFLAG_BIN)) | 8 USE_ENV(NEWTOY(env, "^i", TOYFLAG_USR|TOYFLAG_BIN)) |
5 | 9 |
6 config ENV | 10 config ENV |
7 bool "env" | 11 bool "env" |
8 default y | 12 default y |
9 help | 13 help |
10 usage: env [-i] [FOO=BAR...] [command [option...]] | 14 usage: env [-i] [NAME=VALUE...] [command [option...]] |
11 | 15 |
12 Set the environment for command invocation | 16 Set the environment for command invocation. |
17 | |
18 -i Clear existing environment. | |
13 */ | 19 */ |
14 | 20 |
15 #include "toys.h" | 21 #include "toys.h" |
16 | 22 |
17 extern char **environ; | 23 extern char **environ; |
38 } | 44 } |
39 } | 45 } |
40 | 46 |
41 if (!command) { | 47 if (!command) { |
42 char **ep; | 48 char **ep; |
43 for (ep = environ; *ep; ep++) | 49 for (ep = environ; *ep; ep++) xputs(*ep); |
44 xputs(*ep); | |
45 return; | 50 return; |
46 } else execvp(*command, command); | 51 } else xexec(command); |
47 } | 52 } |