sh: Display the working directory as part of the prompt
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
apio 2023-04-11 22:45:33 +02:00
parent 427662d5f1
commit 1b4f48b92c
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -74,7 +74,17 @@ int main(int argc, char** argv)
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* rc = fgets(cmd, sizeof(cmd), f);