From c7244cc3b729eebdc6b3b8d5843fee0a9dadda75 Mon Sep 17 00:00:00 2001 From: Brian Mayer Date: Fri, 10 Jul 2026 17:20:36 -0300 Subject: [PATCH] getty: add --show-issue to display issue file and exit Print /etc/issue (or -f FILE) with escape expansion and exit, without opening a TTY or prompting for login. Same idea as util-linux agetty --show-issue. \l uses ttyname(0). -f selects the issue file. Signed-off-by: Brian Mayer --- toys/pending/getty.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/toys/pending/getty.c b/toys/pending/getty.c index 1bd795da..aeb000e1 100644 --- a/toys/pending/getty.c +++ b/toys/pending/getty.c @@ -5,13 +5,14 @@ * * No Standard. -USE_GETTY(NEWTOY(getty, "<2t#<0H:I:l:f:iwnmLh", TOYFLAG_SBIN)) +USE_GETTY(NEWTOY(getty, "(show-issue)t#<0H:I:l:f:iwnmLh", TOYFLAG_SBIN)) config GETTY bool "getty" default n help usage: getty [OPTIONS] BAUD_RATE[,BAUD_RATE]... TTY [TERMTYPE] + getty --show-issue [-f ISSUE_FILE] Wait for a modem to dial into serial port, adjust baud rate, call login. @@ -22,6 +23,7 @@ config GETTY -w Wait for CR or LF before sending /etc/issue -i Don't display /etc/issue -f ISSUE_FILE Display ISSUE_FILE instead of /etc/issue + --show-issue Display issue file and exit (no login) -l LOGIN Invoke LOGIN instead of /bin/login -t SEC Terminate after SEC if no login name is read -I INITSTR Send INITSTR before anything else @@ -213,6 +215,16 @@ void getty_main(void) if (!FLAG(f)) TT.f = "/etc/issue"; uname(&TT.uts); + if (FLAG(show_issue)) { + TT.tty_name = ttyname(0); + if (!TT.tty_name) TT.tty_name = "unknown"; + print_issue(); + fflush(stdout); + return; + } + + if (toys.optc < 2) help_exit("BAUD_RATE TTY"); + // parse arguments and set $TERM if (isdigit(**toys.optargs)) { parse_speeds(*toys.optargs); -- 2.39.5