mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Added the $PWD environmental variable to the shell.
This commit is contained in:
parent
b554eb2dfb
commit
042aeb0181
1 changed files with 12 additions and 6 deletions
|
@ -32,6 +32,15 @@
|
||||||
|
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
|
||||||
|
void updatepwd()
|
||||||
|
{
|
||||||
|
const size_t CWD_SIZE = 512;
|
||||||
|
char cwd[CWD_SIZE];
|
||||||
|
const char* wd = getcwd(cwd, CWD_SIZE);
|
||||||
|
if ( !wd ) { wd = "?"; }
|
||||||
|
setenv("PWD", wd, 1);
|
||||||
|
}
|
||||||
|
|
||||||
int runcommandline(const char** tokens)
|
int runcommandline(const char** tokens)
|
||||||
{
|
{
|
||||||
int result = 127;
|
int result = 127;
|
||||||
|
@ -104,6 +113,7 @@ readcmd:
|
||||||
error(0, errno, "cd: %s", newdir);
|
error(0, errno, "cd: %s", newdir);
|
||||||
internalresult = 1;
|
internalresult = 1;
|
||||||
}
|
}
|
||||||
|
updatepwd();
|
||||||
}
|
}
|
||||||
if ( strcmp(argv[0], "exit") == 0 )
|
if ( strcmp(argv[0], "exit") == 0 )
|
||||||
{
|
{
|
||||||
|
@ -224,12 +234,7 @@ void command()
|
||||||
| TERMMODE_ECHO;
|
| TERMMODE_ECHO;
|
||||||
settermmode(0, termmode);
|
settermmode(0, termmode);
|
||||||
|
|
||||||
const size_t CWD_SIZE = 512;
|
printf("root@sortix %s # ", getenv("PWD"));
|
||||||
char cwd[CWD_SIZE];
|
|
||||||
const char* wd = getcwd(cwd, CWD_SIZE);
|
|
||||||
if ( !wd ) { wd = "?"; }
|
|
||||||
|
|
||||||
printf("root@sortix %s # ", wd);
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
const size_t commandsize = 128;
|
const size_t commandsize = 128;
|
||||||
|
@ -298,6 +303,7 @@ int main(int argc, char* argv[])
|
||||||
setenv("$", pidstr, 1);
|
setenv("$", pidstr, 1);
|
||||||
setenv("PPID", ppidstr, 1);
|
setenv("PPID", ppidstr, 1);
|
||||||
setenv("?", "0", 1);
|
setenv("?", "0", 1);
|
||||||
|
updatepwd();
|
||||||
while ( true ) { command(); }
|
while ( true ) { command(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue