sh: Display the working directory as part of the prompt
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
427662d5f1
commit
1b4f48b92c
12
apps/sh.cpp
12
apps/sh.cpp
@ -74,7 +74,17 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
if (file == "-") fputs(getuid() == 0 ? "sh# " : "sh$ ", stdout);
|
if (file == "-")
|
||||||
|
{
|
||||||
|
char* cwd = getcwd(NULL, 0);
|
||||||
|
if (!cwd)
|
||||||
|
{
|
||||||
|
perror("getcwd");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
printf("sh %s%c ", cwd, getuid() == 0 ? '#' : '$');
|
||||||
|
free(cwd);
|
||||||
|
}
|
||||||
|
|
||||||
char cmd[4096];
|
char cmd[4096];
|
||||||
char* rc = fgets(cmd, sizeof(cmd), f);
|
char* rc = fgets(cmd, sizeof(cmd), f);
|
||||||
|
Loading…
Reference in New Issue
Block a user