Index: trunk/src/kash/Makefile.kmk
===================================================================
--- trunk/src/kash/Makefile.kmk	(revision 3476)
+++ trunk/src/kash/Makefile.kmk	(revision 3477)
@@ -42,5 +42,5 @@
 kash_DEFS += KASH_SEPARATE_PARSER_ALLOCATOR KASH_ASYNC_CLOSE_HANDLE
 endif
-kash_DEFS.debug = DEBUG=2
+kash_DEFS.debug = DEBUG=2 K_STRICT
 kash_DEFS.haiku = BSD
 kash_DEFS.linux = BSD
Index: trunk/src/kash/error.c
===================================================================
--- trunk/src/kash/error.c	(revision 3476)
+++ trunk/src/kash/error.c	(revision 3477)
@@ -371,2 +371,24 @@
 	return psh->errmsg_buf;
 }
+
+
+#ifdef K_STRICT
+
+KHLP_DECL(void) kHlpAssertMsg1(const char *pszExpr, const char *pszFile, unsigned iLine, const char *pszFunction)
+{
+	shinstance *psh = shthread_get_shell();
+
+	TRACE((psh,  "Assertion failed in %s --- %s --- %s(%u)\n", pszFunction, pszExpr, pszFile, iLine));
+	dprintf(psh, "Assertion failed in %s --- %s --- %s(%u)\n", pszFunction, pszExpr, pszFile, iLine);
+}
+
+KHLP_DECL(void) kHlpAssertMsg2(const char *pszFormat, ...)
+{
+	shinstance *psh = shthread_get_shell();
+	va_list va;
+	va_start(va, pszFormat);
+	doformat(psh->out2, pszFormat, va);
+	va_end(va);
+}
+
+#endif /* K_STRICT */
Index: trunk/src/kash/eval.c
===================================================================
--- trunk/src/kash/eval.c	(revision 3476)
+++ trunk/src/kash/eval.c	(revision 3477)
@@ -41,5 +41,4 @@
 #endif
 
-#include <assert.h>
 #include <stddef.h>
 #include <stdlib.h>
@@ -528,10 +527,10 @@
 			break;
 		default:
-			assert(redir->type == NHERE || redir->type == NXHERE);
+			kHlpAssert(redir->type == NHERE || redir->type == NXHERE);
 			expfnames->names[i] = NULL;
 			break;
 		}
 	}
-	assert(i == expfnames->count);
+	kHlpAssert(i == expfnames->count);
 
 	/* Do the linking at the end, as nesting happens when we expand backtick arguments. */
@@ -545,5 +544,5 @@
 {
 	redirexpfnames *expfnames = psh->expfnames;
-	assert(expfnames == NULL ? depth == 0 : expfnames->depth == depth || expfnames->depth + 1 == depth);
+	kHlpAssert(expfnames == NULL ? depth == 0 : expfnames->depth == depth || expfnames->depth + 1 == depth);
 	while (expfnames && expfnames->depth >= depth)
 	    expfnames = psh->expfnames = expfnames->prev;
Index: trunk/src/kash/exec.c
===================================================================
--- trunk/src/kash/exec.c	(revision 3476)
+++ trunk/src/kash/exec.c	(revision 3477)
@@ -46,5 +46,4 @@
 #include <stdlib.h>
 #include <stddef.h>
-#include <assert.h>
 
 /*
@@ -307,5 +306,5 @@
 		int suffix;
 		int isreg = stat_pc_exec_exts(psh, cmd, 0, &suffix);
-		assert(isreg > 0);
+		kHlpAssert(isreg > 0);
 	}
 #endif
Index: trunk/src/kash/expand.c
===================================================================
--- trunk/src/kash/expand.c	(revision 3476)
+++ trunk/src/kash/expand.c	(revision 3477)
@@ -45,5 +45,4 @@
 #include <stdlib.h>
 #include <stdio.h>
-#include <assert.h>
 
 /*
Index: trunk/src/kash/main.c
===================================================================
--- trunk/src/kash/main.c	(revision 3476)
+++ trunk/src/kash/main.c	(revision 3477)
@@ -45,5 +45,4 @@
 #endif
 
-#include <assert.h>
 #include <errno.h>
 #include <stdio.h>
Index: trunk/src/kash/memalloc.c
===================================================================
--- trunk/src/kash/memalloc.c	(revision 3476)
+++ trunk/src/kash/memalloc.c	(revision 3477)
@@ -43,5 +43,4 @@
 #include <stdlib.h>
 #include <stddef.h>
-#include <assert.h>
 
 #include "shell.h"
@@ -332,13 +331,13 @@
 	size_t nbytes = (size_t)(end - pstart);
 
-	assert((uintptr_t)end >= (uintptr_t)pstart);
-	/*assert(end[-1] == '\0'); - not if it's followed by ungrabstrackstr(), sigh. */
-	assert(SHELL_ALIGN((uintptr_t)pstart) == (uintptr_t)pstart);
-	assert(stackblocksize(psh) - psh->sstrnleft >= nbytes);
+	kHlpAssert((uintptr_t)end >= (uintptr_t)pstart);
+	/*kHlpAssert(end[-1] == '\0'); - not if it's followed by ungrabstrackstr(), sigh. */
+	kHlpAssert(SHELL_ALIGN((uintptr_t)pstart) == (uintptr_t)pstart);
+	kHlpAssert(stackblocksize(psh) - psh->sstrnleft >= nbytes);
 
 	nbytes = SHELL_ALIGN(nbytes);
 	psh->stacknxt += nbytes;
 	psh->stacknleft -= (int)nbytes;
-	assert(psh->stacknleft >= 0);
+	kHlpAssert(psh->stacknleft >= 0);
 
 	return pstart;
@@ -348,7 +347,7 @@
 ungrabstackstr(shinstance *psh, char *s, char *p)
 {
-	assert((size_t)(psh->stacknxt - p) <= SHELL_SIZE);
-	assert((uintptr_t)s >= (uintptr_t)&psh->stackp->space[0]);
-	assert((uintptr_t)p >= (uintptr_t)s);
+	kHlpAssert((size_t)(psh->stacknxt - p) <= SHELL_SIZE);
+	kHlpAssert((uintptr_t)s >= (uintptr_t)&psh->stackp->space[0]);
+	kHlpAssert((uintptr_t)p >= (uintptr_t)s);
 
 	psh->stacknleft += (int)(psh->stacknxt - s);
@@ -374,5 +373,5 @@
 			while ((top = pst->top) != &pst->first) {
 				pst->top = top->prev;
-				assert(pst->top);
+				kHlpAssert(pst->top);
 				top->prev = NULL;
 				sh_free(psh, top);
@@ -393,5 +392,5 @@
 void pstackpop(shinstance *psh, unsigned target)
 {
-	assert(target <= psh->pstacksize);
+	kHlpAssert(target <= psh->pstacksize);
 	while (target < psh->pstacksize) {
 		unsigned idx = --psh->pstacksize;
@@ -414,5 +413,5 @@
 			if (psh->curpstack == psh->pstack[i])
 				break;
-		assert(i < psh->pstacksize);
+		kHlpAssert(i < psh->pstacksize);
 	}
 # endif
@@ -423,6 +422,6 @@
 {
 	unsigned refs = sh_atomic_inc(&pst->refs);
-	assert(refs > 1);
-	assert(refs < 256 /* bogus, but useful */);
+	kHlpAssert(refs > 1);
+	kHlpAssert(refs < 256 /* bogus, but useful */);
 	return refs;
 }
@@ -533,6 +532,6 @@
 	size_t blocksize;
 
-	assert(pst->avail < nbytes); /* only called when we need more space */
-	assert(tocopy <= pst->avail);
+	kHlpAssert(pst->avail < nbytes); /* only called when we need more space */
+	kHlpAssert(tocopy <= pst->avail);
 
 	/* Double the size used thus far and add some fudge and alignment.  Make
@@ -562,6 +561,6 @@
 		char const * const copysrc = pst->nextbyte;
 		pstallocnewblock(psh, pst, nbytes);
-		assert(pst->avail >= nbytes);
-		assert(pst->avail >= tocopy);
+		kHlpAssert(pst->avail >= nbytes);
+		kHlpAssert(pst->avail >= tocopy);
 		memcpy(pst->nextbyte, copysrc, tocopy);
 	}
@@ -646,5 +645,5 @@
 	size_t const len = end - pst->nextbyte;
 
-	assert(pst->avail - pst->strleft == len);
+	kHlpAssert(pst->avail - pst->strleft == len);
 	TRACE2((psh, "pstmakestrspace: len=%u minbytes=%u (=> %u)\n", len, minbytes, len + minbytes));
 
@@ -657,5 +656,5 @@
 	size_t const len = end - stackblock(psh);
 
-	assert(stackblocksize(psh) - psh->sstrnleft == len);
+	kHlpAssert(stackblocksize(psh) - psh->sstrnleft == len);
 	TRACE2((psh, "pstmakestrspace: len=%u minbytes=%u (=> %u)\n", len, minbytes, len + minbytes));
 
@@ -676,10 +675,10 @@
 	pst->strleft++; 	/* PSTPUTC() already incremented it. */
 	end = pstmakestrspace(psh, 1, end);
-	assert(pst->strleft > 0);
+	kHlpAssert(pst->strleft > 0);
 	pst->strleft--;
 #else
 	psh->sstrnleft++; 	/* PSTPUTC() already incremented it. */
 	end = pstmakestrspace(psh, 1, end);
-	assert(psh->sstrnleft > 0);
+	kHlpAssert(psh->sstrnleft > 0);
 	psh->sstrnleft--;
 #endif
@@ -696,8 +695,8 @@
 	size_t nbytes = (size_t)(end - pstart);
 
-	assert((uintptr_t)end > (uintptr_t)pstart);
-	assert(end[-1] == '\0');
-	assert(SHELL_ALIGN((uintptr_t)pstart) == (uintptr_t)pstart);
-	assert(pst->avail - pst->strleft >= nbytes);
+	kHlpAssert((uintptr_t)end > (uintptr_t)pstart);
+	kHlpAssert(end[-1] == '\0');
+	kHlpAssert(SHELL_ALIGN((uintptr_t)pstart) == (uintptr_t)pstart);
+	kHlpAssert(pst->avail - pst->strleft >= nbytes);
 
 	nbytes = SHELL_ALIGN(nbytes); /** @todo don't align strings, align the other allocations. */
@@ -712,8 +711,8 @@
 	size_t nbytes = (size_t)(end - pstart);
 
-	assert((uintptr_t)end > (uintptr_t)pstart);
-	assert(end[-1] == '\0');
-	assert(SHELL_ALIGN((uintptr_t)pstart) == (uintptr_t)pstart);
-	assert(stackblocksize(psh) - psh->sstrnleft >= nbytes);
+	kHlpAssert((uintptr_t)end > (uintptr_t)pstart);
+	kHlpAssert(end[-1] == '\0');
+	kHlpAssert(SHELL_ALIGN((uintptr_t)pstart) == (uintptr_t)pstart);
+	kHlpAssert(stackblocksize(psh) - psh->sstrnleft >= nbytes);
 
 	nbytes = SHELL_ALIGN(nbytes); /** @todo don't align strings, align the other allocations. */
Index: trunk/src/kash/memalloc.h
===================================================================
--- trunk/src/kash/memalloc.h	(revision 3476)
+++ trunk/src/kash/memalloc.h	(revision 3477)
@@ -74,6 +74,6 @@
 #define STPUTC(psh, c, p)           (--(psh)->sstrnleft >= 0? (*p++ = (c)) : (p = growstackstr(psh), *p++ = (c)))
 #define CHECKSTRSPACE(psh, n, p)    { if ((psh)->sstrnleft < n) p = makestrspace(psh); }
-#define USTPUTC(psh, c, p)          do { assert((psh)->sstrnleft > 0); \
-                                         assert(p - (char *)stackblock(psh) == stackblocksize(psh) - (psh)->sstrnleft); \
+#define USTPUTC(psh, c, p)          do { kHlpAssert((psh)->sstrnleft > 0); \
+                                         kHlpAssert(p - (char *)stackblock(psh) == stackblocksize(psh) - (psh)->sstrnleft); \
                                          --(psh)->sstrnleft; *p++ = (c); } while (0)
 #define STACKSTRNUL(psh, p)         ((psh)->sstrnleft == 0? (p = growstackstr(psh), *p = '\0') : (*p = '\0'))
@@ -114,8 +114,8 @@
 # define PSTCHECKSTRSPACE(psh, n, p) do { \
         if ((psh)->curpstack->strleft >= (n)) {/*likely*/} \
-        else { (p) = pstmakestrspace(psh, (n), (p)); assert((psh)->curpstack->strleft >= (n)); } \
+        else { (p) = pstmakestrspace(psh, (n), (p)); kHlpAssert((psh)->curpstack->strleft >= (n)); } \
     } while (0)
 # define PSTUPUTC(psh, c, p) do { \
-        assert((psh)->curpstack->strleft > 0); \
+        kHlpAssert((psh)->curpstack->strleft > 0); \
         (psh)->curpstack->strleft -= 1; \
         *(p)++ = (c); \
@@ -137,6 +137,6 @@
 # define PSTARTSTACKSTR(psh, p)      do { (p) = (psh)->stacknxt; (psh)->sstrnleft = (psh)->stacknleft; } while (0)
 # define PSTCHECKSTRSPACE(psh, n, p) do { if ((psh)->sstrnleft >= (n)) {/*likely*/} \
-                                         else { (p) = pstmakestrspace(psh, (n), (p)); assert((psh)->sstrnleft >= (n)); } } while (0)
-# define PSTUPUTC(psh, c, p)         do { assert((psh)->sstrnleft > 0); --(psh)->sstrnleft; *(p)++ = (c); } while (0)
+                                         else { (p) = pstmakestrspace(psh, (n), (p)); kHlpAssert((psh)->sstrnleft >= (n)); } } while (0)
+# define PSTUPUTC(psh, c, p)         do { kHlpAssert((psh)->sstrnleft > 0); --(psh)->sstrnleft; *(p)++ = (c); } while (0)
 # define PSTPUTC(psh, c, p)          do { if (--(psh)->sstrnleft >= 0) *(p)++ = (c); else (p) = pstputcgrow(psh, (p), (c)); } while (0)
 # define PSTPUTSTRN(psh, str, n, p)  do { if ((psh)->sstrnleft >= (n)) {/*likely?*/} else (p) = pstmakestrspace(psh, (n), (p)); \
Index: trunk/src/kash/options.c
===================================================================
--- trunk/src/kash/options.c	(revision 3476)
+++ trunk/src/kash/options.c	(revision 3477)
@@ -41,5 +41,4 @@
 #endif
 
-#include <assert.h>
 #include <stdlib.h>
 
@@ -109,5 +108,5 @@
 	    i++;
 	}
-	assert(psh->arg0 != NULL);
+	kHlpAssert(psh->arg0 != NULL);
     }
 
@@ -131,5 +130,5 @@
     psh->shellparam.reset  = inherit->shellparam.reset;
     psh->shellparam.nparam = left = inherit->shellparam.nparam;
-    assert(left >= 0);
+    kHlpAssert(left >= 0);
     psh->shellparam.p = (char **)ckmalloc(psh, (left + 1) * sizeof(psh->shellparam.p[0]));
     psh->shellparam.p[left] = NULL;
@@ -142,5 +141,5 @@
     if (inherit->shellparam.optnext) {
 	size_t idx = (size_t)(inherit->shellparam.optnext - inherit->shellparam.p);
-	assert(idx <= inherit->shellparam.nparam);
+	kHlpAssert(idx <= inherit->shellparam.nparam);
 	if (idx <= inherit->shellparam.nparam)
 	    psh->shellparam.optnext = &psh->shellparam.p[idx];
@@ -169,5 +168,5 @@
 	    off--;
 	}
-	assert(psh->shellparam.optptr != NULL);
+	kHlpAssert(psh->shellparam.optptr != NULL);
     }
 
@@ -225,5 +224,5 @@
 	psh->shellparam.p = psh->argptr;
 	psh->shellparam.reset = 1;
-	/* assert(shellparam.malloc == 0 && shellparam.nparam == 0); */
+	/* kHlpAssert(shellparam.malloc == 0 && shellparam.nparam == 0); */
 	while (*psh->argptr) {
 		psh->shellparam.nparam++;
Index: trunk/src/kash/parser.c
===================================================================
--- trunk/src/kash/parser.c	(revision 3476)
+++ trunk/src/kash/parser.c	(revision 3477)
@@ -43,5 +43,4 @@
 #define SH_MEMALLOC_NO_STACK
 #include <stdlib.h>
-#include <assert.h>
 
 #include "shell.h"
Index: trunk/src/kash/redir.c
===================================================================
--- trunk/src/kash/redir.c	(revision 3476)
+++ trunk/src/kash/redir.c	(revision 3477)
@@ -43,5 +43,4 @@
 #include <sys/types.h>
 #include <limits.h>         /* PIPE_BUF */
-#include <assert.h>
 #include <string.h>
 #include <errno.h>
@@ -158,5 +157,5 @@
 	idxexpfname = 0;
 	for (n = redir, idxexpfname = 0 ; n ; n = n->nfile.next, idxexpfname++) {
-		assert(idxexpfname < psh->expfnames->count);
+		kHlpAssert(idxexpfname < psh->expfnames->count);
 		fd = n->nfile.fd;
 		try = 0;
@@ -196,5 +195,5 @@
 			openredirect(psh, n, memory, flags, psh->expfnames->names[idxexpfname]);
 	}
-	assert(!redir || idxexpfname == psh->expfnames->count);
+	kHlpAssert(!redir || idxexpfname == psh->expfnames->count);
 	if (memory[1])
 		psh->out1 = &psh->memout;
Index: trunk/src/kash/setmode.c
===================================================================
--- trunk/src/kash/setmode.c	(revision 3476)
+++ trunk/src/kash/setmode.c	(revision 3477)
@@ -44,5 +44,4 @@
 #include <sys/stat.h>
 
-#include <assert.h>
 #include <ctype.h>
 #include <errno.h>
@@ -76,5 +75,5 @@
 
 #ifndef _DIAGASSERT
-# define _DIAGASSERT assert
+# define _DIAGASSERT kHlpAssert
 #endif
 
Index: trunk/src/kash/shfile.c
===================================================================
--- trunk/src/kash/shfile.c	(revision 3476)
+++ trunk/src/kash/shfile.c	(revision 3477)
@@ -33,5 +33,4 @@
 #include <stdio.h>
 #include <string.h>
-#include <assert.h>
 
 #if K_OS == K_OS_WINDOWS
@@ -235,5 +234,5 @@
         if (decrement_pending)
         {
-            assert(g_shfile_async_close.num_pending > 0);
+            kHlpAssert(g_shfile_async_close.num_pending > 0);
             g_shfile_async_close.num_pending -= 1;
         }
@@ -242,7 +241,7 @@
         if (idx != g_shfile_async_close.idx_write % K_ELEMENTS(g_shfile_async_close.handles))
         {
-            assert(g_shfile_async_close.num_pending > 0);
+            kHlpAssert(g_shfile_async_close.num_pending > 0);
             toclose = g_shfile_async_close.handles[idx];
-            assert(toclose);
+            kHlpAssert(toclose);
             g_shfile_async_close.handles[idx] = NULL;
             g_shfile_async_close.idx_read = (idx + 1) % K_ELEMENTS(g_shfile_async_close.handles);
@@ -254,5 +253,5 @@
             {
                 BOOL rc = SetEvent(g_shfile_async_close.evt_sync);
-                assert(rc);
+                kHlpAssert(rc);
                 g_shfile_async_close.signal_sync = FALSE;
             }
@@ -265,5 +264,5 @@
         {
             BOOL rc = CloseHandle(toclose);
-            assert(rc);
+            kHlpAssert(rc);
             decrement_pending = K_TRUE;
         }
@@ -271,5 +270,5 @@
         {
             DWORD dwRet = WaitForSingleObject(g_shfile_async_close.evt_workers, 10000 /*ms*/);
-            assert(dwRet == WAIT_OBJECT_0 || dwRet == WAIT_TIMEOUT);
+            kHlpAssert(dwRet == WAIT_OBJECT_0 || dwRet == WAIT_TIMEOUT);
             decrement_pending = K_FALSE;
         }
@@ -303,5 +302,5 @@
     {
         /* Write the handle to the ring buffer: */
-        assert(g_shfile_async_close.handles[idx] == NULL);
+        kHlpAssert(g_shfile_async_close.handles[idx] == NULL);
         g_shfile_async_close.handles[idx] = toclose;
         g_shfile_async_close.idx_write    = idx_next;
@@ -311,5 +310,5 @@
 
         ret = SetEvent(g_shfile_async_close.evt_workers);
-        assert(ret);
+        kHlpAssert(ret);
         if (ret)
         {
@@ -322,5 +321,5 @@
                 intptr_t hThread = _beginthreadex(NULL /*security*/, 0 /*stack_size*/, shfile_async_close_handle_thread,
                                                   NULL /*arg*/, 0 /*initflags*/, &tid);
-                assert(hThread != -1);
+                kHlpAssert(hThread != -1);
                 if (hThread != -1)
                 {
@@ -375,5 +374,5 @@
         {
             BOOL rc = ResetEvent(g_shfile_async_close.evt_sync);
-            assert(rc); K_NOREF(rc);
+            kHlpAssert(rc); K_NOREF(rc);
 
             g_shfile_async_close.signal_sync = K_TRUE;
@@ -384,6 +383,6 @@
         TRACE2((NULL, "shfile_async_close_sync: Calling WaitForSingleObject...\n"));
         dwRet = WaitForSingleObject(g_shfile_async_close.evt_sync, 10000 /*ms*/);
-        assert(dwRet == WAIT_OBJECT_0);
-        assert(g_shfile_async_close.num_pending == 0);
+        kHlpAssert(dwRet == WAIT_OBJECT_0);
+        kHlpAssert(g_shfile_async_close.num_pending == 0);
         TRACE2((NULL, "shfile_async_close_sync: WaitForSingleObject returned %u...\n", dwRet));
     }
@@ -441,5 +440,5 @@
     KU64 ns = shfile_nano_ts();
     BOOL fRc = CloseHandle((HANDLE)native);
-    assert(fRc); K_NOREF(fRc);
+    kHlpAssert(fRc); K_NOREF(fRc);
     ns = shfile_nano_ts() - ns;
     if (ns > 1000000)
@@ -448,5 +447,5 @@
 #  else
     BOOL fRc = CloseHandle((HANDLE)native);
-    assert(fRc); K_NOREF(fRc);
+    kHlpAssert(fRc); K_NOREF(fRc);
 #  endif
     }
@@ -656,5 +655,5 @@
 {
     shmtx_leave(&pfdtab->mtx, ptmp);
-    assert(file);
+    kHlpAssert(file);
     (void)file;
 }
@@ -1069,5 +1068,5 @@
 
                             fd2 = shfile_insert(pfdtab, (intptr_t)h, fFlags, fFlags2, i, "shtab_init", NULL);
-                            assert(fd2 == i); (void)fd2;
+                            kHlpAssert(fd2 == i); (void)fd2;
                             if (fd2 != i)
                                 rc = -1;
@@ -1095,5 +1094,5 @@
                                 fFlags2 = SHFILE_FLAGS_FILE;
                             fd2 = shfile_insert(pfdtab, (intptr_t)hFile, fFlags, fFlags2, i, "shtab_init", NULL);
-                            assert(fd2 == i); (void)fd2;
+                            kHlpAssert(fd2 == i); (void)fd2;
                             if (fd2 != i)
                                 rc = -1;
@@ -1136,5 +1135,5 @@
                                 native = fd;
                             fd2 = shfile_insert(pfdtab, native, oflags, fFlags2, fd, "shtab_init", NULL);
-                            assert(fd2 == fd); (void)fd2;
+                            kHlpAssert(fd2 == fd); (void)fd2;
                             if (fd2 != fd)
                                 rc = -1;
@@ -1268,8 +1267,8 @@
 #if K_OS == K_OS_WINDOWS
                     BOOL rc = CloseHandle((HANDLE)pfd->native);
-                    assert(rc == TRUE); K_NOREF(rc);
+                    kHlpAssert(rc == TRUE); K_NOREF(rc);
 #else
                     int rc = close((int)pfd->native);
-                    assert(rc == 0); K_NOREF(rc);
+                    kHlpAssert(rc == 0); K_NOREF(rc);
 #endif
                     pfd->fd     = -1;
@@ -1330,5 +1329,5 @@
             TRACE2((NULL, "shfile_set_inherit_win: %p -> %p (set=%d)\n", pfd->native, hFile, set));
             if (!CloseHandle((HANDLE)pfd->native))
-                assert(0);
+                kHlpAssert(0);
             pfd->native = (intptr_t)hFile;
         }
@@ -1336,5 +1335,5 @@
         {
             err = GetLastError();
-            assert(0);
+            kHlpAssert(0);
             hFile = (HANDLE)pfd->native;
         }
@@ -2043,7 +2042,7 @@
     {
 # if K_OS == K_OS_WINDOWS
-        assert(SEEK_SET == FILE_BEGIN);
-        assert(SEEK_CUR == FILE_CURRENT);
-        assert(SEEK_END == FILE_END);
+        kHlpAssert(SEEK_SET == FILE_BEGIN);
+        kHlpAssert(SEEK_CUR == FILE_CURRENT);
+        kHlpAssert(SEEK_END == FILE_END);
         rc = SetFilePointer((HANDLE)file->native, off, NULL, whench);
         if (rc == INVALID_SET_FILE_POINTER)
@@ -2096,5 +2095,5 @@
                 {
 # if K_OS == K_OS_WINDOWS
-                    assert(0);
+                    kHlpAssert(0);
                     errno = EINVAL;
                     rc = -1;
Index: trunk/src/kash/shfork-win.c
===================================================================
--- trunk/src/kash/shfork-win.c	(revision 3476)
+++ trunk/src/kash/shfork-win.c	(revision 3477)
@@ -6,5 +6,4 @@
 #include <string.h>
 #include <locale.h>
-#include <assert.h>
 #include "shinstance.h"
 #include <Windows.h>
@@ -85,6 +84,6 @@
     g_stack_base  = shfork_string_to_ptr(argv[5], argv[0], "--stack-base");
     g_stack_limit = shfork_string_to_ptr(argv[7], argv[0], "--stack-limit");
-    assert((uintptr_t)stack_ptr < (uintptr_t)g_stack_base);
-    assert((uintptr_t)stack_ptr > (uintptr_t)g_stack_limit);
+    kHlpAssert((uintptr_t)stack_ptr < (uintptr_t)g_stack_base);
+    kHlpAssert((uintptr_t)stack_ptr > (uintptr_t)g_stack_limit);
 
     /*
@@ -183,6 +182,6 @@
     int rc = 0;
 
-    assert((uintptr_t)stack_ptr < (uintptr_t)g_stack_base);
-    assert((uintptr_t)stack_ptr > (uintptr_t)g_stack_limit);
+    kHlpAssert((uintptr_t)stack_ptr < (uintptr_t)g_stack_base);
+    kHlpAssert((uintptr_t)stack_ptr > (uintptr_t)g_stack_limit);
 
     /*
Index: trunk/src/kash/shheap.c
===================================================================
--- trunk/src/kash/shheap.c	(revision 3476)
+++ trunk/src/kash/shheap.c	(revision 3477)
@@ -32,5 +32,4 @@
 #include <string.h>
 #include <stdlib.h>
-#include <assert.h>
 #include "shinstance.h"
 
@@ -105,5 +104,5 @@
 # define SHHEAP_CHECK()         shheap_check()
 # define SHHEAP_CHECK_2()       shheap_check()
-# define SHHEAP_ASSERT(expr)    assert(expr)
+# define SHHEAP_ASSERT(expr)    kHlpAssert(expr)
 # define SHHEAP_POISON_PSH(p,v) ((shinstance *)(v))
 # define SHHEAP_POISON_NULL(v)  ((void *)(v))
Index: trunk/src/kash/shinstance.c
===================================================================
--- trunk/src/kash/shinstance.c	(revision 3476)
+++ trunk/src/kash/shinstance.c	(revision 3477)
@@ -32,5 +32,4 @@
 #include <string.h>
 #include <stdlib.h>
-#include <assert.h>
 #ifdef _MSC_VER
 # include <process.h>
@@ -174,5 +173,5 @@
 {
 #if K_OS == K_OS_WINDOWS
-    assert(ptmp->i == 0x42);
+    kHlpAssert(ptmp->i == 0x42);
     LeaveCriticalSection((CRITICAL_SECTION *)pmtx);
     ptmp->i = 0x21;
@@ -190,5 +189,5 @@
 void sh_init_globals(void)
 {
-    assert(g_sh_mtx.au64[SHMTX_MAGIC_IDX] != SHMTX_MAGIC);
+    kHlpAssert(g_sh_mtx.au64[SHMTX_MAGIC_IDX] != SHMTX_MAGIC);
     shmtx_init(&g_sh_mtx);
 #ifndef SH_FORKED_MODE
@@ -317,5 +316,5 @@
     sh_free(psh, psh->threadarg);
     psh->threadarg = NULL;
-    assert(!psh->subshellstatus);
+    kHlpAssert(!psh->subshellstatus);
     if (psh->subshellstatus)
     {
@@ -910,5 +909,5 @@
                 else
                 {
-                    assert(old.sa_handler == SIG_IGN);
+                    kHlpAssert(old.sa_handler == SIG_IGN);
                     shold.sh_handler = SH_SIG_IGN;
                 }
@@ -919,5 +918,5 @@
                 /* fake */
 #ifndef _MSC_VER
-                assert(0);
+                kHlpAssert(0);
                 old.sa_handler = SIG_DFL;
                 old.sa_flags = 0;
@@ -945,5 +944,5 @@
             for (cur = g_sh_head; cur; cur = cur->next)
             {
-                assert(cur->sigactions[signo].sh_handler == SH_SIG_UNK);
+                kHlpAssert(cur->sigactions[signo].sh_handler == SH_SIG_UNK);
                 cur->sigactions[signo] = shold;
             }
@@ -988,5 +987,5 @@
     else
     {
-        assert(pfn != SH_SIG_ERR);
+        kHlpAssert(pfn != SH_SIG_ERR);
         pfn(pshDst, signo);
     }
@@ -1125,9 +1124,9 @@
                 && signo != SIGTTOU
                 && signo != SIGCONT)
-                assert(0);
+                kHlpAssert(0);
         }
 #else
         if (sigaction(signo, &g_sig_state[signo].sa, NULL))
-            assert(0);
+            kHlpAssert(0);
 #endif
 
@@ -1417,6 +1416,6 @@
 {
     unsigned refs = sh_atomic_dec(&sts->refs);
-    assert(refs > 1);
-    assert(refs < 16);
+    kHlpAssert(refs > 1);
+    kHlpAssert(refs < 16);
     return refs;
 }
@@ -1428,5 +1427,5 @@
 {
     unsigned refs = sh_atomic_dec(&sts->refs);
-    assert(refs < ~(unsigned)0/4);
+    kHlpAssert(refs < ~(unsigned)0/4);
     if (refs == 0)
     {
@@ -1463,5 +1462,5 @@
 # if K_OS == K_OS_WINDOWS
         BOOL rc = ResetEvent((HANDLE)sts->towaiton);
-        assert(rc); K_NOREF(rc);
+        kHlpAssert(rc); K_NOREF(rc);
 # endif
     }
@@ -1477,5 +1476,5 @@
         if (!sts->towaiton)
         {
-            assert(0);
+            kHlpAssert(0);
             sh_free(psh, sts);
             return NULL;
@@ -1508,9 +1507,9 @@
         sts->status = W_EXITCODE(iExit, 0);
         sts->done   = K_TRUE;
-        rc = SetEvent((HANDLE)sts->towaiton); assert(rc); K_NOREF(rc);
+        rc = SetEvent((HANDLE)sts->towaiton); kHlpAssert(rc); K_NOREF(rc);
 
         hThread = (HANDLE)sts->hThread;
         sts->hThread = 0;
-        rc = CloseHandle(hThread); assert(rc);
+        rc = CloseHandle(hThread); kHlpAssert(rc);
 
         shsubshellstatus_release(psh, sts);
@@ -1781,5 +1780,5 @@
             {
                 rc = psh->children[i].subshellstatus->done;
-                assert(rc);
+                kHlpAssert(rc);
                 if (rc)
                 {
@@ -1812,5 +1811,5 @@
         {
             rc = CloseHandle(psh->children[i].hChild);
-            assert(rc);
+            kHlpAssert(rc);
         }
 
@@ -2115,5 +2114,5 @@
                  */
                 dwErr = WaitForSingleObject(ProcInfo.hProcess, INFINITE);
-                assert(dwErr == WAIT_OBJECT_0);
+                kHlpAssert(dwErr == WAIT_OBJECT_0);
 
                 if (GetExitCodeProcess(ProcInfo.hProcess, &dwExitCode))
@@ -2129,5 +2128,5 @@
                 /* this shouldn't happen... */
                 TRACE2((psh, "sh_execve: GetExitCodeProcess failed: %u\n", GetLastError()));
-                assert(0);
+                kHlpAssert(0);
                 errno = EINVAL;
             }
@@ -2226,5 +2225,5 @@
     shpid pgid = psh->pgid;
 #ifndef _MSC_VER
-    assert(pgid == getpgrp());
+    kHlpAssert(pgid == getpgrp());
 #endif
 
@@ -2244,10 +2243,10 @@
         shpid pgid = psh->pgid;
 #ifndef _MSC_VER
-        assert(pgid == getpgrp());
+        kHlpAssert(pgid == getpgrp());
 #endif
     }
     else
     {
-        assert(0);
+        kHlpAssert(0);
         errno = ESRCH;
         pgid = -1;
Index: trunk/src/kash/show.c
===================================================================
--- trunk/src/kash/show.c	(revision 3476)
+++ trunk/src/kash/show.c	(revision 3477)
@@ -44,5 +44,4 @@
 #include <stdarg.h>
 #include <stdlib.h>
-#include <assert.h>
 
 #include "shell.h"
@@ -293,5 +292,5 @@
 	if (pos > sizeof(psh->tracebuf)) {
 		char *end;
-		assert(0);
+		kHlpAssert(0);
 		end = memchr(psh->tracebuf, '\0', sizeof(psh->tracebuf));
 		pos = end ? end - &psh->tracebuf[0] : 0;
Index: trunk/src/kash/shthread.c
===================================================================
--- trunk/src/kash/shthread.c	(revision 3476)
+++ trunk/src/kash/shthread.c	(revision 3477)
@@ -27,5 +27,4 @@
 #include "shthread.h"
 #include "shinstance.h"
-#include <assert.h>
 
 #if K_OS == K_OS_WINDOWS
@@ -66,8 +65,8 @@
     {
         sh_tls = TlsAlloc();
-        assert(sh_tls != TLS_OUT_OF_INDEXES);
+        kHlpAssert(sh_tls != TLS_OUT_OF_INDEXES);
     }
     if (!TlsSetValue(sh_tls, psh))
-        assert(0);
+        kHlpAssert(0);
 
 #elif K_OS == K_OS_OS2
@@ -75,17 +74,17 @@
     {
         sh_tls = __libc_TLSAlloc();
-        assert(sh_tls != -1);
+        kHlpAssert(sh_tls != -1);
     }
     if (__libc_TLSSet(sh_tls, psh) == -1)
-        assert(0);
+        kHlpAssert(0);
 #else
     if (!sh_tls_inited)
     {
         if (pthread_key_create(&sh_tls, NULL) != 0)
-            assert(0);
+            kHlpAssert(0);
         sh_tls_inited = 1;
     }
     if (pthread_setspecific(sh_tls, psh) != 0)
-        assert(0);
+        kHlpAssert(0);
 #endif
 }
Index: trunk/src/kash/shtypes.h
===================================================================
--- trunk/src/kash/shtypes.h	(revision 3476)
+++ trunk/src/kash/shtypes.h	(revision 3477)
@@ -30,4 +30,5 @@
 
 #include "k/kTypes.h" /* Use these, not the ones below. */
+#include "k/kHlpAssert.h"
 
 #include <sys/types.h>
Index: trunk/src/kash/var.c
===================================================================
--- trunk/src/kash/var.c	(revision 3476)
+++ trunk/src/kash/var.c	(revision 3477)
@@ -41,5 +41,4 @@
 #endif
 
-#include <assert.h>
 #include <stddef.h>
 #include <stdlib.h>
@@ -303,5 +302,5 @@
 						} else
 							break;
-					assert(left < 256 /*whatever, just no rollover*/);
+					kHlpAssert(left < 256 /*whatever, just no rollover*/);
 				}
 				*dst = *vsrc;
@@ -336,5 +335,5 @@
 
 			dst->vp = find_var(psh, vsrc->vp->text, NULL, NULL);
-			assert(dst->vp);
+			kHlpAssert(dst->vp);
 
 			*ppdst = dst;
