Index: /trunk/Ohana/src/opihi/cmd.basic/Makefile
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/Makefile	(revision 16210)
+++ /trunk/Ohana/src/opihi/cmd.basic/Makefile	(revision 16211)
@@ -22,4 +22,5 @@
 $(SRC)/config.$(ARCH).o     \
 $(SRC)/continue.$(ARCH).o   \
+$(SRC)/dirname.$(ARCH).o     \
 $(SRC)/date.$(ARCH).o	     \
 $(SRC)/echo.$(ARCH).o	     \
@@ -34,4 +35,5 @@
 $(SRC)/macro.$(ARCH).o	     \
 $(SRC)/memory.$(ARCH).o     \
+$(SRC)/mkdir.$(ARCH).o     \
 $(SRC)/module.$(ARCH).o     \
 $(SRC)/output.$(ARCH).o     \
Index: /trunk/Ohana/src/opihi/cmd.basic/dirname.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/dirname.c	(revision 16211)
+++ /trunk/Ohana/src/opihi/cmd.basic/dirname.c	(revision 16211)
@@ -0,0 +1,34 @@
+# include "basic.h"
+
+int dirname_opihi (int argc, char **argv) {
+
+  int N;
+  char *dirName, *varName;
+
+  varName = NULL;
+  if ((N = get_argument (argc, argv, "-var"))) {
+    remove_argument (N, &argc, argv);
+    varName = strcreate (argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
+  if (argc < 2) {
+    gprint (GP_ERR, "USAGE: dirname (path) [-var name]\n");
+    return (FALSE);
+  }
+
+  dirName = pathname (argv[1]);
+
+  if (varName == NULL) {
+    gprint (GP_LOG, "%s\n", dirName);
+  } else {
+    set_str_variable (varName, dirName);
+    free (varName);
+  }    
+
+  free (dirName);
+  return (TRUE);
+}
+
+// XXX need to add mode option
+// XXX need to respect umask (need umask command?)
Index: /trunk/Ohana/src/opihi/cmd.basic/init.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/init.c	(revision 16210)
+++ /trunk/Ohana/src/opihi/cmd.basic/init.c	(revision 16211)
@@ -6,4 +6,5 @@
 int cd              PROTO((int, char **));
 int date            PROTO((int, char **));
+int dirname_opihi   PROTO((int, char **));
 int echo            PROTO((int, char **));
 int exec_last       PROTO((int, char **));
@@ -20,4 +21,5 @@
 int macro      	    PROTO((int, char **));
 int memory          PROTO((int, char **));
+int mkdir_opihi	    PROTO((int, char **));
 int module    	    PROTO((int, char **));
 int output     	    PROTO((int, char **));
@@ -45,4 +47,5 @@
   {"cd",      	    cd,                 "change directory"},
   {"date",    	    date,               "get current date"},
+  {"dirname",       dirname_opihi,      "built-in dirname function"},
   {"echo",    	    echo,               "type this line *"},
   {"break",   	    exec_break,         "escape from function *"},
@@ -61,4 +64,5 @@
   {"macro",   	    macro,              "deal with the macros *"}, 
   {"memory",        memory,             "long listing of the allocated memory"},
+  {"mkdir",         mkdir_opihi,        "built-in mkdir command"},
   {"module",        module,             "load script file from the modules directories"},
   {"output",  	    output,             "redirect output to file"},
Index: /trunk/Ohana/src/opihi/cmd.basic/mkdir.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/mkdir.c	(revision 16211)
+++ /trunk/Ohana/src/opihi/cmd.basic/mkdir.c	(revision 16211)
@@ -0,0 +1,34 @@
+# include "basic.h"
+
+int mkdir_opihi (int argc, char **argv) {
+
+  int mode, status;
+  struct stat fstats;
+
+  if (argc < 2) {
+    gprint (GP_ERR, "USAGE: mkdir (path)\n");
+    return (FALSE);
+  }
+
+  mode = S_IRWXU | S_IRWXG;
+
+  status = stat (argv[1], &fstats);
+  if (!status) {
+    // argv[1] exists, is it a directory?
+    if (!S_ISDIR(fstats.st_mode)) {
+      gprint (GP_ERR, "cannot create directory %s: is an existing file\n", argv[1]);
+      return (FALSE);
+    }
+    return (TRUE);
+  }
+
+  status = mkdirhier (argv[1], mode);
+  if (status == -1) {
+    gprint (GP_ERR, "cannot create directory %s\n", argv[1]);
+    return (FALSE);
+  }
+  return (TRUE);
+}
+
+// XXX need to add mode option
+// XXX need to respect umask (need umask command?)
