From 71cb1ceaaa894f642e2d294684d6ac83e965137a Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Fri, 25 Jul 2025 03:30:40 -0400 Subject: usr: osh: Print banner from /etc/motd Signed-off-by: Ian Moffett --- usr.bin/osh/osh.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'usr.bin/osh/osh.c') diff --git a/usr.bin/osh/osh.c b/usr.bin/osh/osh.c index af7f4ab..3b41747 100644 --- a/usr.bin/osh/osh.c +++ b/usr.bin/osh/osh.c @@ -426,6 +426,25 @@ open_script(const char *pathname) return 0; } +static void +dump_file(const char *pathname) +{ + FILE *file; + char buf[64]; + int fd; + + file = fopen(pathname, "r"); + if (file == NULL) { + return; + } + + while (fgets(buf, sizeof(buf), file) != NULL) { + printf("%s", buf); + } + + fclose(file); +} + int main(int argc, char **argv) { @@ -442,7 +461,7 @@ main(int argc, char **argv) running = 1; bell_fd = open("/dev/beep", O_WRONLY); - puts(WELCOME); + dump_file("/etc/motd"); while (running) { printf(PROMPT, getlogin()); -- cgit v1.2.3