mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:27:34 +00:00
Add a /bin/tty command that prints the current tty.
Also fix ttyname() syscall to include "/dev/" in the name.
This commit is contained in:
parent
4605b549d6
commit
c7d5ce6b5a
6 changed files with 28 additions and 5 deletions
|
@ -11,6 +11,7 @@
|
|||
struct GlobalState {
|
||||
String cwd;
|
||||
String username;
|
||||
const char* ttyname_short { nullptr };
|
||||
char ttyname[32];
|
||||
char hostname[32];
|
||||
};
|
||||
|
@ -160,7 +161,7 @@ static void greeting()
|
|||
perror("uname");
|
||||
return;
|
||||
}
|
||||
printf("\n%s/%s on %s\n\n", uts.sysname, uts.machine, g->ttyname);
|
||||
printf("\n%s/%s on %s\n\n", uts.sysname, uts.machine, g->ttyname_short);
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
|
@ -172,6 +173,8 @@ int main(int, char**)
|
|||
rc = ttyname_r(0, g->ttyname, sizeof(g->ttyname));
|
||||
if (rc < 0)
|
||||
perror("ttyname_r");
|
||||
else
|
||||
g->ttyname_short = strrchr(g->ttyname, '/') + 1;
|
||||
{
|
||||
auto* pw = getpwuid(getuid());
|
||||
if (pw)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue