From c7d5ce6b5a2b031d8fe5d319f158d91be66ca998 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Wed, 31 Oct 2018 21:45:36 +0100 Subject: Add a /bin/tty command that prints the current tty. Also fix ttyname() syscall to include "/dev/" in the name. --- Userland/sh.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Userland/sh.cpp') diff --git a/Userland/sh.cpp b/Userland/sh.cpp index 3a660c0d01..f218ae7290 100644 --- a/Userland/sh.cpp +++ b/Userland/sh.cpp @@ -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) -- cgit v1.2.3