[PATCH] shell/lash.c: set environment variable
Shaun Jackman
sjackman at gmail.com
Thu May 25 19:31:10 UTC 2006
On 5/12/06, Rob Landley <rob at landley.net> wrote:
...
> One big reason I'm on the fence about this is I want to do all this _right_
> with bbsh. Unfortunately, since I went to day job land it's a lot harder to
> find time to work on the "ok, I'm going to disappear for 2 weeks now" type
> projects than it is to grab half an hour here and two hours there. And
> unfortunately, getting bbsh from where it is to ready to check in is
> definitely a "see you in 2 weeks" type of project. (I try doing marathon
> sessions over weekends, but that leaves me exhausted and listless during the
> work week...)
>
> I'll figure something out...
bbsh sounds like a great idea, but as long is I'm stuck with lash, I'd
appreciate this minor band-aid being applied. The promised patch
follows.
My wrist is still in a fiberglass, hopefully for not much longer than
another week.
Cheers,
Shaun
2006-05-25 Shaun Jackman <sjackman at gmail.com>
* shell/lash.c (run_command): Allow setting an environment
variable without an explicit `export'.
--- shell/lash.c f5fc197ef657bbc0b4aef0360505dbe0044b3bd4
+++ shell/lash.c a9a72989d31101bcfc710fc0651b4e03269f7606
@@ -1358,6 +1358,12 @@
* is doomed to failure, and doesn't work on bash, either.
*/
if (newjob->num_progs == 1) {
+ /* Check if the command sets an environment variable. */
+ if (strchr(child->argv[0], '=') != NULL) {
+ child->argv[1] = child->argv[0];
+ return builtin_export(child);
+ }
+
for (x = bltins; x->cmd; x++) {
if (strcmp(child->argv[0], x->cmd) == 0 ) {
int rcode;
-------------- next part --------------
2006-05-25 Shaun Jackman <sjackman at gmail.com>
* shell/lash.c (run_command): Allow setting an environment
variable without an explicit `export'.
--- shell/lash.c f5fc197ef657bbc0b4aef0360505dbe0044b3bd4
+++ shell/lash.c a9a72989d31101bcfc710fc0651b4e03269f7606
@@ -1358,6 +1358,12 @@
* is doomed to failure, and doesn't work on bash, either.
*/
if (newjob->num_progs == 1) {
+ /* Check if the command sets an environment variable. */
+ if (strchr(child->argv[0], '=') != NULL) {
+ child->argv[1] = child->argv[0];
+ return builtin_export(child);
+ }
+
for (x = bltins; x->cmd; x++) {
if (strcmp(child->argv[0], x->cmd) == 0 ) {
int rcode;
More information about the busybox
mailing list