Index: /trunk/src/kash/Makefile.kmk
===================================================================
--- /trunk/src/kash/Makefile.kmk	(revision 1226)
+++ /trunk/src/kash/Makefile.kmk	(revision 1227)
@@ -15,4 +15,5 @@
 kmk_ash_TEMPLATE = BIN
 kmk_ash_DEFS = lint SHELL SMALL
+kmk_ash_DEFS += SH_STUB_MODE # for the time being.
 kmk_ash_DEFS.debug = DEBUG
 kmk_ash_DEFS.linux = BSD
Index: /trunk/src/kash/shfile.c
===================================================================
--- /trunk/src/kash/shfile.c	(revision 1226)
+++ /trunk/src/kash/shfile.c	(revision 1227)
@@ -29,8 +29,12 @@
 
 #ifdef KBUILD_OS_WINDOWS
-//# include <io.h>
+# include <limits.h>
+# ifndef PIPE_BUF
+#  define PIPE_BUF 512
+# endif
 #else
 # include <unistd.h>
 # include <fcntl.h>
+# include <dirent.h>
 #endif
 
@@ -38,71 +42,169 @@
 int shfile_open(shfdtab *pfdtab, const char *name, unsigned flags, mode_t mode)
 {
-//    return open(name, flags);
-    return -1;
+#ifdef SH_PURE_STUB_MODE
+    return -1;
+#elif defined(SH_STUB_MODE)
+    return open(name, flags, mode);
+#else
+#endif
 }
 
 int shfile_pipe(shfdtab *pfdtab, int fds[2])
 {
-    return -1;
+#ifdef SH_PURE_STUB_MODE
+    return -1;
+#elif defined(SH_STUB_MODE)
+# ifdef _MSC_VER
+    return _pipe(fds, PIPE_BUF, O_BINARY);
+# else
+    return pipe(fds);
+# endif
+#else
+#endif
 }
 
 int shfile_dup(shfdtab *pfdtab, int fd)
 {
-    return -1;
+#ifdef SH_PURE_STUB_MODE
+    return -1;
+#elif defined(SH_STUB_MODE)
+    return dup(fd);
+#else
+#endif
 }
 
 int shfile_close(shfdtab *pfdtab, unsigned fd)
 {
-    return -1;
+#ifdef SH_PURE_STUB_MODE
+    return -1;
+#elif defined(SH_STUB_MODE)
+    return close(fd);
+#else
+#endif
 }
 
 long shfile_read(shfdtab *pfdtab, int fd, void *buf, size_t len)
 {
-    return -1;
+#ifdef SH_PURE_STUB_MODE
+    return -1;
+#elif defined(SH_STUB_MODE)
+# ifdef _MSC_VER
+    return read(fd, buf, (unsigned)len);
+# else
+    return read(fd, buf, len);
+# endif
+#else
+#endif
 }
 
 long shfile_write(shfdtab *pfdtab, int fd, const void *buf, size_t len)
 {
-    return -1;
+#ifdef SH_PURE_STUB_MODE
+    return -1;
+#elif defined(SH_STUB_MODE)
+# ifdef _MSC_VER
+    return write(fd, buf, (unsigned)len);
+# else
+    return write(fd, buf, len);
+# endif
+#else
+#endif
 }
 
 long shfile_lseek(shfdtab *pfdtab, int fd, long off, int whench)
 {
-    return -1;
+#ifdef SH_PURE_STUB_MODE
+    return -1;
+#elif defined(SH_STUB_MODE)
+    return lseek(fd, off, whench);
+#else
+#endif
 }
 
 int shfile_fcntl(shfdtab *pfdtab, int fd, int cmd, int arg)
 {
-    return -1;
+#ifdef SH_PURE_STUB_MODE
+    return -1;
+#elif defined(SH_STUB_MODE)
+# ifdef _MSC_VER
+    return -1;
+# else
+    return fcntl(fd, cmd, arg);
+# endif
+#else
+#endif
 }
 
 int shfile_stat(shfdtab *pfdtab, const char *path, struct stat *pst)
 {
-    return -1;
+#ifdef SH_PURE_STUB_MODE
+    return -1;
+#elif defined(SH_STUB_MODE)
+    return stat(path, pst);
+#else
+#endif
 }
 
 int shfile_lstat(shfdtab *pfdtab, const char *link, struct stat *pst)
 {
-    return -1;
+#ifdef SH_PURE_STUB_MODE
+    return -1;
+#elif defined(SH_STUB_MODE)
+# ifdef _MSC_VER
+    return stat(link, pst);
+# else
+    return lstat(link, pst);
+# endif
+#else
+#endif
 }
 
 int shfile_chdir(shfdtab *pfdtab, const char *path)
 {
-    return -1;
+#ifdef SH_PURE_STUB_MODE
+    return -1;
+#elif defined(SH_STUB_MODE)
+# ifdef _MSC_VER //???
+    return chdir(path);
+# else
+    return chdir(path);
+# endif
+#else
+#endif
 }
 
 char *shfile_getcwd(shfdtab *pfdtab, char *buf, int len)
 {
-    return NULL;
+#ifdef SH_PURE_STUB_MODE
+    return NULL;
+#elif defined(SH_STUB_MODE)
+    return getcwd(buf, len);
+#else
+#endif
 }
 
 int shfile_access(shfdtab *pfdtab, const char *path, int type)
 {
-    return -1;
+#ifdef SH_PURE_STUB_MODE
+    return -1;
+#elif defined(SH_STUB_MODE)
+# ifdef _MSC_VER
+    type &= ~X_OK;
+    return access(path, type);
+# else
+    return access(path, type);
+# endif
+#else
+#endif
 }
 
 int shfile_isatty(shfdtab *pfdtab, int fd)
 {
+#ifdef SH_PURE_STUB_MODE
     return 0;
+#elif defined(SH_STUB_MODE)
+    return isatty(fd);
+#else
+#endif
 }
 
@@ -110,10 +212,24 @@
 int shfile_ioctl(shfdtab *pfdtab, int fd, unsigned long request, void *buf)
 {
-    return -1;
+#ifdef SH_PURE_STUB_MODE
+    return -1;
+#elif defined(SH_STUB_MODE)
+# ifdef _MSC_VER
+    return -1;
+# else
+    return ioctl(fd, request, buf);
+# endif
+#else
+#endif
 }
 
 mode_t shfile_get_umask(shfdtab *pfdtab)
 {
+#ifdef SH_PURE_STUB_MODE
     return 022;
+#elif defined(SH_STUB_MODE)
+    return 022;
+#else
+#endif
 }
 
@@ -121,14 +237,40 @@
 shdir *shfile_opendir(shfdtab *pfdtab, const char *dir)
 {
-    return NULL;
+#ifdef SH_PURE_STUB_MODE
+    return NULL;
+#elif defined(SH_STUB_MODE)
+# ifdef _MSC_VER
+    return NULL;
+# else
+    return (shdir *)opendir(dir);
+# endif
+#else
+#endif
 }
 
 shdirent *shfile_readdir(struct shdir *pdir)
 {
-    return NULL;
+#ifdef SH_PURE_STUB_MODE
+    return NULL;
+#elif defined(SH_STUB_MODE)
+# ifdef _MSC_VER
+    return NULL;
+# else
+    struct dirent *pde = readdir((DIR *)pdir);
+    return pde ? (shdirent *)&pde->d_name[0] : NULL;
+# endif
+#else
+#endif
 }
 
 void shfile_closedir(struct shdir *pdir)
 {
-
-}
+#ifdef SH_PURE_STUB_MODE
+    return NULL;
+#elif defined(SH_STUB_MODE)
+# ifndef _MSC_VER
+    closedir((DIR *)pdir);
+# endif
+#else
+#endif
+}
