commit: c30afc7d4ed2addc578ff05aab691715ee8694aa
parent 2233af5614138e680095ca959e419c6dec74ed19
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Mon, 8 Sep 2025 20:30:19 +0200
oksh: define "~/.kshrc" as DEFAULT_ENV, fixing PS1 issues
Diffstat:
3 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/init.c b/init.c
@@ -83,13 +83,9 @@ main(int argc, char *argv[])
fprintf(stderr, "Failed to create /dev/null: %s\n", strerror(errno));
}
- // PS1 shouldn't be exported but '\h\$ ' is an *awful* default
- // and oksh also doesn't sources ksh-specific files by default
- setenv("PS1", "$? $PWD # ", 1);
-
fprintf(stderr, "Launching: /bin/oksh /init.sh\n");
- if(execl("/bin/oksh", "/bin/oksh", "/init.sh", (char *)0) < 0)
+ if(execl("/bin/oksh", "-sh", "/init.sh", (char *)0) < 0)
{
fprintf(stderr, "Failed to execute: %s\n", strerror(errno));
return 1;
diff --git a/make-root.sh b/make-root.sh
@@ -144,6 +144,7 @@ ln -s usr/lib lib
ln -s usr/bin bin
ln -s usr/bin sbin
mkdir -m 777 tmp
+mkdir -m 700 root
cat >etc/passwd <<EOF
root:x:0:0:root:/root:/bin/sh
@@ -162,6 +163,11 @@ exec date -f %Y-%m-%dT%TZ $(date +%Y-%m-%dT%TZ)
EOF
chmod +x etc/setdate.sh
+cat >root/.kshrc <<'EOF'
+PS1="$? $PWD # "
+EOF
+chmod +x root/.kshrc
+
for i in fd stderr stdin stdout; do
ln -fs proc/self/$i dev/$i
done
diff --git a/src/oksh-7.6_pconfig.h b/src/oksh-7.6_pconfig.h
@@ -13,3 +13,4 @@
#define HAVE_TIMERADD
#define HAVE_TIMERCLEAR
#define HAVE_TIMERSUB
+#define DEFAULT_ENV "~/.kshrc"