diff options
author | Andreas Kling <awesomekling@gmail.com> | 2018-10-31 21:45:36 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2018-10-31 21:46:05 +0100 |
commit | c7d5ce6b5a2b031d8fe5d319f158d91be66ca998 (patch) | |
tree | 887bdac95040605f56b1d8235f84951220048678 /Userland/sh.cpp | |
parent | 4605b549d6483116420bc5e5f54d9591f84986a1 (diff) | |
download | serenity-c7d5ce6b5a2b031d8fe5d319f158d91be66ca998.zip |
Add a /bin/tty command that prints the current tty.
Also fix ttyname() syscall to include "/dev/" in the name.
Diffstat (limited to 'Userland/sh.cpp')
-rw-r--r-- | Userland/sh.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
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) |