1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

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.
This commit is contained in:
Martijn Dekker 2020-09-01 09:08:04 +01:00
parent c607c48c84
commit 5e21cacf7a

View file

@ -1127,7 +1127,11 @@ int sh_type(register const char *path)
{ {
s++; s++;
t |= SH_TYPE_SH; 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; t |= SH_TYPE_POSIX;
if ((t & SH_TYPE_KSH) && *s == '9' && *(s+1) == '3') if ((t & SH_TYPE_KSH) && *s == '9' && *(s+1) == '3')
s += 2; s += 2;