Everytime I check ramdisks I wonder of what use the ksh string is:
$ what bsd.rd
bsd.rd:
OpenBSD 7.2-current (RAMDISK_CD) #965: Sun Feb 5 09:58:01 MST
2023
PD KSH v5.2.14 99/07/13.2
$OpenBSD: cert.pem,v 1.25 2022/07/11 09:05:16 sthen Exp $
ksh(1) says
KSH_VERSION
The version of the shell and the date the version was created
(read-only).
The installer does not care about SH_VERSION or KSH_VERSION or \V and \v PS1
escape sequences for full and short version strings.
Disable it with SMALL to save a few bits and get
$ what obj/bsd.rd
obj/bsd.rd:
OpenBSD 7.2-current (RAMDISK_CD) #5: Wed Feb 8 04:10:37 CET
2023
$OpenBSD: cert.pem,v 1.25 2022/07/11 09:05:16 sthen Exp $
Feedback? Objection? OK?
Index: bin/ksh/lex.c
===================================================================
RCS file: /cvs/src/bin/ksh/lex.c,v
retrieving revision 1.78
diff -u -p -r1.78 lex.c
--- bin/ksh/lex.c 15 Jan 2018 14:58:05 -0000 1.78
+++ bin/ksh/lex.c 8 Feb 2023 02:47:26 -0000
@@ -1335,6 +1335,7 @@ dopprompt(const char *sp, int ntruncate,
case 'u': /* '\' 'u' username */
strlcpy(strbuf, username, sizeof strbuf);
break;
+#ifndef SMALL
case 'v': /* '\' 'v' version (short) */
p = strchr(ksh_version, ' ');
if (p)
@@ -1350,6 +1351,7 @@ dopprompt(const char *sp, int ntruncate,
case 'V': /* '\' 'V' version (long) */
strlcpy(strbuf, ksh_version, sizeof strbuf);
break;
+#endif /* SMALL */
case 'w': /* '\' 'w' cwd */
p = str_val(global("PWD"));
n = strlen(str_val(global("HOME")));
Index: bin/ksh/main.c
===================================================================
RCS file: /cvs/src/bin/ksh/main.c,v
retrieving revision 1.98
diff -u -p -r1.98 main.c
--- bin/ksh/main.c 28 Jun 2019 13:34:59 -0000 1.98
+++ bin/ksh/main.c 8 Feb 2023 02:53:49 -0000
@@ -81,7 +81,9 @@ static const char initifs[] = "IFS= \t\n
static const char initsubs[] = "${PS2=> } ${PS3=#? } ${PS4=+ }";
static const char *initcoms [] = {
+#ifndef SMALL
"typeset", "-r", "KSH_VERSION", NULL,
+#endif /* SMALL */
"typeset", "-x", "SHELL", "PATH", "HOME", "PWD", "OLDPWD", NULL,
"typeset", "-ir", "PPID", NULL,
"typeset", "-i", "OPTIND=1", NULL,
@@ -110,7 +112,9 @@ static const char *initcoms [] = {
char username[_PW_NAME_LEN + 1];
+#ifndef SMALL
#define version_param (initcoms[2])
+#endif /* SMALL */
/* The shell uses its own variation on argv, to build variables like
* $0 and $@.
@@ -247,7 +251,9 @@ main(int argc, char *argv[])
(strlen(kshname) >= 3 &&
!strcmp(&kshname[strlen(kshname) - 3], "/sh"))) {
Flag(FSH) = 1;
+#ifndef SMALL
version_param = "SH_VERSION";
+#endif /* SMALL */
}
/* Set edit mode to emacs by default, may be overridden
@@ -296,8 +302,10 @@ main(int argc, char *argv[])
}
ppid = getppid();
setint(global("PPID"), (int64_t) ppid);
+#ifndef SMALL
/* setstr can't fail here */
setstr(global(version_param), ksh_version, KSH_RETURN_ERROR);
+#endif /* SMALL */
/* execute initialization statements */
for (wp = (char**) initcoms; *wp != NULL; wp++) {
Index: distrib/special/ksh/Makefile
===================================================================
RCS file: /cvs/src/distrib/special/ksh/Makefile,v
retrieving revision 1.5
diff -u -p -r1.5 Makefile
--- distrib/special/ksh/Makefile 1 Aug 2017 14:30:07 -0000 1.5
+++ distrib/special/ksh/Makefile 8 Feb 2023 02:45:49 -0000
@@ -4,7 +4,7 @@ PROG= ksh
SRCS= alloc.c c_ksh.c c_sh.c c_test.c c_ulimit.c edit.c emacs.c eval.c \
exec.c expr.c history.c io.c jobs.c lex.c mail.c main.c \
misc.c path.c shf.c syn.c table.c trap.c tree.c tty.c var.c \
- version.c vi.c
+ vi.c
DEFS= -Wall -DEMACS -DSMALL
CFLAGS+=${DEFS} -I. -I${.CURDIR}/../../../bin/ksh
-I${.CURDIR}/../../../lib/libc/gen