Commit Diff


commit - 4abecf9ce46680bf5dd3824554eb0a506bb51524
commit + 91804d72273e18ab9f4022f3dc1cc7d90eb3fea0
blob - 3cd78310a5985d04386099d255c1ef3de54f9311
blob + f54e4d5ce8bf42c1bcc589a246a62c2f4e464936
--- st.c
+++ st.c
@@ -5,6 +5,7 @@
 #include <fcntl.h>
 #include <limits.h>
 #include <locale.h>
+#include <pwd.h>
 #include <stdarg.h>
 #include <stdbool.h>
 #include <stdio.h>
@@ -881,11 +882,23 @@ void
 execsh(void) {
 	char **args;
 	char *envshell = getenv("SHELL");
+	const struct passwd *pass = getpwuid(getuid());
+	char buf[sizeof(long) * 8 + 1];
 
 	unsetenv("COLUMNS");
 	unsetenv("LINES");
 	unsetenv("TERMCAP");
 
+	if(pass) {
+		setenv("LOGNAME", pass->pw_name, 1);
+		setenv("USER", pass->pw_name, 1);
+		setenv("SHELL", pass->pw_shell, 0);
+		setenv("HOME", pass->pw_dir, 0);
+	}
+
+	snprintf(buf, sizeof(buf), "%lu", xw.win);
+	setenv("WINDOWID", buf, 1);
+
 	signal(SIGCHLD, SIG_DFL);
 	signal(SIGHUP, SIG_DFL);
 	signal(SIGINT, SIG_DFL);
@@ -2795,8 +2808,8 @@ main(int argc, char *argv[]) {
 run:
 	setlocale(LC_CTYPE, "");
 	tnew(80, 24);
-	ttynew();
 	xinit();
+	ttynew();
 	selinit();
 	run();
 	return 0;