Index: /trunk/src/kash/shfile.c
===================================================================
--- /trunk/src/kash/shfile.c	(revision 2308)
+++ /trunk/src/kash/shfile.c	(revision 2309)
@@ -1221,4 +1221,6 @@
         sh_free(psh, free_me);
     }
+    else
+        rc = -1;
 #else
     rc = chdir(path);
@@ -1275,12 +1277,32 @@
 }
 
+/**
+ * access().
+ */
 int shfile_access(shfdtab *pfdtab, const char *path, int type)
 {
+    int         rc;
+#ifdef SHFILE_IN_USE
+    char        abspath[SHFILE_MAX_PATH];
+
+    rc = shfile_make_path(pfdtab, path, &abspath[0]);
+    if (!rc)
+    {
 # ifdef _MSC_VER
-    type &= ~X_OK;
-    return access(path, type);
-# else
-    return access(path, type);
-# endif
+        if (type & X_OK)
+            type = (type & ~X_OK) | R_OK;
+# endif
+        rc = access(abspath, type);
+    }
+#else
+# ifdef _MSC_VER
+    if (type & X_OK)
+        type = (type & ~X_OK) | R_OK;
+# endif
+    rc = access(path, type);
+#endif
+
+    TRACE2((NULL, "shfile_access(,%s,%#x) -> %d [%d]\n", path, type, rc, errno));
+    return rc;
 }
 
@@ -1297,5 +1319,5 @@
     {
 # if K_OS == K_OS_WINDOWS
-        errno = ENOSYS;
+        rc = (file->shflags & SHFILE_FLAGS_TYPE_MASK) == SHFILE_FLAGS_TTY;
 # else
         rc = isatty(file->native);
