Index: /trunk/Ohana/src/opihi/cmd.astro/multifit.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.astro/multifit.c	(revision 16058)
+++ /trunk/Ohana/src/opihi/cmd.astro/multifit.c	(revision 16059)
@@ -141,5 +141,5 @@
     }
   }
-  dgaussj (a, Ndim, b, 1);
+  dgaussjordan (a, b, Ndim, 1);
 
   Ny = 0;
Index: /trunk/Ohana/src/opihi/cmd.basic/shell.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/shell.c	(revision 16058)
+++ /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);
   }
Index: /trunk/Ohana/src/opihi/cmd.basic/test/list.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/test/list.sh	(revision 16058)
+++ /trunk/Ohana/src/opihi/cmd.basic/test/list.sh	(revision 16059)
@@ -75,5 +75,5 @@
   echo "Number of list elements: $check4:n"
  end
- if (("$check4:0" != "This ") || ("$check4:1" != "is ") || ("$check4:2" != "a ") || ("$check4:3" != "list "))
+ if (("$check4:0" != "This") || ("$check4:1" != "is") || ("$check4:2" != "a") || ("$check4:3" != "list"))
   $PASS = 0
   echo "List element does not return correctly!"
Index: /trunk/Ohana/src/opihi/cmd.basic/test/output.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/test/output.sh	(revision 16058)
+++ /trunk/Ohana/src/opihi/cmd.basic/test/output.sh	(revision 16059)
@@ -23,5 +23,5 @@
  output stdout
  $line = `cat testout.txt`
- if ("$line" == "This is a test. ")
+ if ("$line" == "This is a test.")
    $PASS = 1
  else
Index: /trunk/Ohana/src/opihi/cmd.basic/test/scan.sh
===================================================================
--- /trunk/Ohana/src/opihi/cmd.basic/test/scan.sh	(revision 16058)
+++ /trunk/Ohana/src/opihi/cmd.basic/test/scan.sh	(revision 16059)
@@ -20,10 +20,10 @@
  output stdout
  scan test_file.txt fscan
- if ("$fscan" != "This ")
+ if ("$fscan" != "This")
   $PASS = 0
   echo "Default not working!"
  end
  scan test_file.txt fscan 4
- if ("$fscan" != "test ")
+ if ("$fscan" != "test")
   $PASS = 0
   echo "Scan failure!"
Index: /trunk/Ohana/src/opihi/cmd.data/fit.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/fit.c	(revision 16058)
+++ /trunk/Ohana/src/opihi/cmd.data/fit.c	(revision 16059)
@@ -118,5 +118,5 @@
       }
     }
-    if (!dgaussj (c, nterm, b, 1)) goto escape;
+    if (!dgaussjordan (c, b, nterm, 1)) goto escape;
 
     /* generate fitted values */
Index: /trunk/Ohana/src/opihi/cmd.data/fit2d.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/fit2d.c	(revision 16058)
+++ /trunk/Ohana/src/opihi/cmd.data/fit2d.c	(revision 16059)
@@ -161,5 +161,5 @@
     }
 
-    dgaussj (c, wterm, b, 1);
+    dgaussjordan (c, b, wterm, 1);
 
     /** test print **/
Index: /trunk/Ohana/src/opihi/cmd.data/gaussj.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/gaussj.c	(revision 16058)
+++ /trunk/Ohana/src/opihi/cmd.data/gaussj.c	(revision 16059)
@@ -34,5 +34,5 @@
   }
 
-  status = dgaussj (a, N, b, 1);
+  status = dgaussjordan (a, b, N, 1);
 
   for (i = 0; i < N; i++) {
Index: /trunk/Ohana/src/opihi/cmd.data/tvcolors.c
===================================================================
--- /trunk/Ohana/src/opihi/cmd.data/tvcolors.c	(revision 16058)
+++ /trunk/Ohana/src/opihi/cmd.data/tvcolors.c	(revision 16059)
@@ -3,5 +3,5 @@
 int tvcolors (int argc, char **argv) {
   
-  int N, kapa, Nchannel;
+  int N, kapa;
   char *name;
   KapaImageData data;
Index: /trunk/Ohana/src/opihi/lib.data/mrq2dmin.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.data/mrq2dmin.c	(revision 16058)
+++ /trunk/Ohana/src/opihi/lib.data/mrq2dmin.c	(revision 16059)
@@ -90,5 +90,5 @@
 
   /* keep this test in here? */
-  if (!fgaussj (talpha, Npar, tbeta, 1)) {
+  if (!fgaussjordan (talpha, tbeta, Npar, 1)) {
     lambda *= 10.0;
     return (ochisq);
@@ -183,5 +183,5 @@
 float **mrq2dcovar (int Npar) {
 
-  fgaussj (alpha, Npar, beta, 1);
+  fgaussjordan (alpha, beta, Npar, 1);
   return (alpha);
 
Index: /trunk/Ohana/src/opihi/lib.data/mrqmin.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.data/mrqmin.c	(revision 16058)
+++ /trunk/Ohana/src/opihi/lib.data/mrqmin.c	(revision 16059)
@@ -60,5 +60,5 @@
   }
 
-  fgaussj (talpha, Npar, tbeta, 1);
+  fgaussjordan (talpha, tbeta, Npar, 1);
 
   for (j = 0; j < Npar; j++) partry[j] = par[j] - tbeta[j][0];
@@ -137,5 +137,5 @@
 /* don't invoke this in the middle of a run, only near the end */ 
 float **mrqcovar (int Npar) {
-  fgaussj (alpha, Npar, beta, 1);
+  fgaussjordan (alpha, beta, Npar, 1);
   return (alpha);
 } 
Index: /trunk/Ohana/src/opihi/lib.shell/expand_vectors.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.shell/expand_vectors.c	(revision 16058)
+++ /trunk/Ohana/src/opihi/lib.shell/expand_vectors.c	(revision 16059)
@@ -113,5 +113,5 @@
       if (J < 0) J += buf[0].header.Naxis[1];
       ptr = (float *) buf[0].matrix.buffer;
-      f1 = ptr[I + J*buf[0].header.Naxis[1]];
+      f1 = ptr[I + J*buf[0].header.Naxis[0]];
     } else {
       if ((vec = SelectVector (tmpline, OLDVECTOR, TRUE)) == NULL) goto dumpline;
Index: /trunk/Ohana/src/opihi/lib.shell/parse.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.shell/parse.c	(revision 16058)
+++ /trunk/Ohana/src/opihi/lib.shell/parse.c	(revision 16059)
@@ -177,5 +177,5 @@
 
       fptr = (float *) buf[0].matrix.buffer;
-      fptr[Nx + Ny*buf[0].header.Naxis[1]] = atof (val);
+      fptr[Nx + Ny*buf[0].header.Naxis[0]] = atof (val);
     } else {
       if ((vec = SelectVector (V0, OLDVECTOR, TRUE)) == NULL) goto error;
Index: /trunk/Ohana/src/opihi/mana/fitcontour.c
===================================================================
--- /trunk/Ohana/src/opihi/mana/fitcontour.c	(revision 16058)
+++ /trunk/Ohana/src/opihi/mana/fitcontour.c	(revision 16059)
@@ -57,5 +57,5 @@
   C[1][2] = C[2][1];
     
-  dgaussj (C, NTERM, B, 1);
+  dgaussjordan (C, B, NTERM, 1);
   
   /** this is somewhat weak: if the object is too elongated, Rmin can be < 0 **/
