summaryrefslogtreecommitdiff
path: root/Userland/sh.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/sh.cpp')
-rw-r--r--Userland/sh.cpp5
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)