Index: trunk/Ohana/src/opihi/cmd.basic/shell.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.basic/shell.c	(revision 15868)
+++ trunk/Ohana/src/opihi/cmd.basic/shell.c	(revision 16059)
@@ -1,3 +1,6 @@
 # include "basic.h"
+
+static char *defshell = "/bin/sh";
+static char *cmdflag = "-c";
 
 int shell (int argc, char **argv) {
@@ -6,17 +9,35 @@
   int exit_status;
   int wait_status;
-  int result;
-  char **args;
+  int result, length;
+  char **args, *shell;
 
-  ALLOCATE (args, char *, argc);
+  shell = getenv ("SHELL");
+  if (shell == NULL) shell = defshell;
+
+  // we are creating a command of the form /bin/sh -c argv[1] argv[2] etc, where
+  // the argv[1], etc elements are concatenated into a single string
+  ALLOCATE (args, char *, 4);
+  args[0] = shell;
+  args[1] = cmdflag;
+
+  length = 0;
   for (i = 1; i < argc; i++) {
-    args[i-1] = argv[i];
+    length += strlen(argv[i]) + 1;
   }
-  args[i-1] = NULL;
+  
+  ALLOCATE (args[2], char, length);
+  args[2][0] = 0;
+  for (i = 1; i < argc; i++) {
+    strcat (args[2], argv[i]);
+    if (i < argc - 1) strcat (args[2], " ");
+  }
+  args[3] = NULL;
+
+  // send the commands to the shell specified in the env variable SHELL, or else /bin/sh
 
   // use execvp to enable a timeout on the system call 
   pid = fork ();
   if (!pid) { /* must be child process */
-    execvp (args[0], args);
+    execvp (shell, args);
     exit (1);
   }
