1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

Expand variables before running shell builtins.

This commit is contained in:
Jonas 'Sortie' Termansen 2013-10-02 00:54:27 +02:00
parent 3785beb7f5
commit dd5a59e5f6

View file

@ -132,6 +132,22 @@ readcmd:
cmdnext = cmdend + 1; cmdnext = cmdend + 1;
argv = (char**) (tokens + cmdstart); argv = (char**) (tokens + cmdstart);
updateenv();
char statusstr[32];
sprintf(statusstr, "%i", status);
setenv("?", statusstr, 1);
for ( char** argp = argv; *argp; argp++ )
{
char* arg = *argp;
if ( arg[0] != '$' )
continue;
arg = getenv(arg+1);
if ( !arg )
arg = (char*) "";
*argp = arg;
}
internal = false; internal = false;
internalresult = 0; internalresult = 0;
if ( strcmp(argv[0], "cd") == 0 ) if ( strcmp(argv[0], "cd") == 0 )
@ -247,20 +263,6 @@ readcmd:
} }
} }
updateenv();
char statusstr[32];
sprintf(statusstr, "%i", status);
setenv("?", statusstr, 1);
for ( char** argp = argv; *argp; argp++ )
{
char* arg = *argp;
if ( arg[0] != '$' ) { continue; }
arg = getenv(arg+1);
if ( !arg ) { arg = (char*) ""; }
*argp = arg;
}
if ( !strcmp(argv[0], "env") ) if ( !strcmp(argv[0], "env") )
{ {
for ( size_t i = 0; i < envlength(); i++ ) for ( size_t i = 0; i < envlength(); i++ )