> ksh won't start after this change. The problem is that it will try to
> assign the return value of getppid() to PPID *after* PPID was made read
> only.
Such is the price of not testing last-minute changes. When ksh
processes a typeset command, it sets the read-only flag before
attempting to convert the string to an integer. We can reproduce
the issue like so:
$ NUM=42
$ typeset -ir NUM
ksh: NUM: is read only
We can get around this problem by separating out the two lines.
Index: main.c
===================================================================
RCS file: /cvs/src/bin/ksh/main.c,v
retrieving revision 1.79
diff -u -p -r1.79 main.c
--- main.c 4 Mar 2016 15:11:06 -0000 1.79
+++ main.c 27 May 2016 13:18:01 -0000
@@ -85,6 +85,7 @@ static const char *initcoms [] = {
"typeset", "-r", "KSH_VERSION", NULL,
"typeset", "-x", "SHELL", "PATH", "HOME", NULL,
"typeset", "-i", "PPID", NULL,
+ "typeset", "-r", "PPID", NULL,
"typeset", "-i", "OPTIND=1", NULL,
"eval", "typeset -i RANDOM MAILCHECK=\"${MAILCHECK-600}\"
SECONDS=\"${SECONDS-0}\" TMOUT=\"${TMOUT-0}\"", NULL,
"alias",