From 5e21cacf7ad4b55aaf5814173b017e795b5962f9 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Tue, 1 Sep 2020 09:08:04 +0100 Subject: [PATCH] init: fix sh detection (re: 921bbcae) ksh was enabling POSIX mode on init if it was invoked as any name that merely started with 'sh' (after parsing initial 'r'). This included shcomp, which was bad news. src/cmd/ksh93/sh/init.c: sh_type(): - Check that the 'sh' is at the end of the string by checking for a final zero byte. - On Windows (_WINIX, see src/lib/libast/features/common), allow for a file name extension (sh.exe) by checking for a dot as well. --- src/cmd/ksh93/sh/init.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cmd/ksh93/sh/init.c b/src/cmd/ksh93/sh/init.c index a73d176c0..7f04b3572 100644 --- a/src/cmd/ksh93/sh/init.c +++ b/src/cmd/ksh93/sh/init.c @@ -1127,7 +1127,11 @@ int sh_type(register const char *path) { s++; t |= SH_TYPE_SH; - if (!(t & SH_TYPE_KSH)) +#if _WINIX + if (!(t & SH_TYPE_KSH) && (!*s || *s == '.')) +#else + if (!(t & SH_TYPE_KSH) && !*s) +#endif t |= SH_TYPE_POSIX; if ((t & SH_TYPE_KSH) && *s == '9' && *(s+1) == '3') s += 2;