Index: /trunk/Ohana/src/opihi/lib.shell/expand_vectors.c
===================================================================
--- /trunk/Ohana/src/opihi/lib.shell/expand_vectors.c	(revision 38001)
+++ /trunk/Ohana/src/opihi/lib.shell/expand_vectors.c	(revision 38002)
@@ -1,3 +1,7 @@
 # include "opihi.h"
+
+// converts a[], a[4], a[2][3] to their numeric values
+// add a?[] and a?[][] as equivalent to $?a
+// a[][?]
 
 char *expand_vectors (char *line) {
@@ -5,5 +9,5 @@
   char *newline, *tmpline, strValue[128], *val;
   char *L, *N, *p, *q, *p2, *w;
-  int n, I, J, size, showLength, NLINE, Noff, isBuffer, inRange;
+  int n, I, J, size, showLength, showXsize, showYsize, checkType, NLINE, Noff, isBuffer, inRange;
   float *ptr;
   double f1;
@@ -41,6 +45,10 @@
     val = NULL;
     showLength = FALSE;
+    showXsize  = FALSE;
+    showYsize  = FALSE;
+
     if (n == 0) {
       showLength = TRUE;
+      showXsize  = TRUE;
     } else {
       tmpline = strncreate (p+1, n);
@@ -60,8 +68,8 @@
       p2 = strchr (q + 1, ']');
       if (p2 != NULL) {
-	if (showLength) {
-	  gprint (GP_ERR, "unsupported : name[][..]\n"); 
-	  goto asVector;
-	}
+	// if (showLength) {
+	//   gprint (GP_ERR, "unsupported : name[][..]\n"); 
+	//   goto asVector;
+	// }
 
 	isBuffer = TRUE;
@@ -71,14 +79,16 @@
 	val = NULL;
 	if (n == 0) {
-	  gprint (GP_ERR, "unsupported : name[..][]\n"); 
-	  isBuffer = FALSE;
-	  goto asVector;
-	} 
-	tmpline = strncreate (q+2, n);
-	val = dvomath (1, &tmpline, &size, 0);
-	free (tmpline);
-	if (val == NULL) {
-	  isBuffer = FALSE;
-	  goto asVector; /* not a valid vector subscript */
+	  showYsize = TRUE;
+	  // gprint (GP_ERR, "unsupported : name[..][]\n"); 
+	  // isBuffer = FALSE;
+	  // goto asVector;
+	}  else {
+	  tmpline = strncreate (q+2, n);
+	  val = dvomath (1, &tmpline, &size, 0);
+	  free (tmpline);
+	  if (val == NULL) {
+	    isBuffer = FALSE;
+	    goto asVector; /* not a valid vector subscript */
+	  }
 	}
 	J = 0; 
@@ -93,4 +103,9 @@
   asVector:
     /* find vector/buffer name */
+    checkType = FALSE;
+    if (*(p-1) == '?') {
+      checkType = TRUE;
+      p--;
+    }
     for (w = p - 1; (w >= line) && !OHANA_WHITESPACE(*w) && (isalnum(*w) || (*w == ':') || (*w == '_')); w--);
     w ++;
@@ -99,6 +114,22 @@
 
     if (isBuffer) {
-      if ((buf = SelectBuffer (tmpline, OLDBUFFER, TRUE)) == NULL) goto dumpline;
-
+      buf = SelectBuffer (tmpline, OLDBUFFER, !checkType);
+      if (checkType) {
+	f1 = (buf != NULL);
+	goto skipBuffer;
+      } 
+      if (showXsize && showYsize) {
+	gprint (GP_ERR, "ambiguous size option buf[][]\n"); 
+	goto dumpline;
+      }
+      if (buf == NULL) goto dumpline;
+      if (showXsize) {
+	f1 = buf[0].header.Naxis[0];
+	goto skipBuffer;
+      }
+      if (showYsize) {
+	f1 = buf[0].header.Naxis[1];
+	goto skipBuffer;
+      }
       /* find buffer element */
       inRange = TRUE;
@@ -116,19 +147,25 @@
       f1 = ptr[I + J*buf[0].header.Naxis[0]];
     } else {
-      if ((vec = SelectVector (tmpline, OLDVECTOR, TRUE)) == NULL) goto dumpline;
-
-      /* find vector element */
-      if (showLength) {
-	f1 = vec[0].Nelements;
+      vec = SelectVector (tmpline, OLDVECTOR, !checkType);
+      if (checkType) {
+	f1 = (vec != NULL);
       } else {
-	if ((I >= vec[0].Nelements) || (I < -1*vec[0].Nelements)) {
-	  gprint (GP_ERR, "vector subscript out of range\n"); 
-	  goto escape;
+	if (vec == NULL) goto dumpline;
+
+	/* find vector element */
+	if (showLength) {
+	  f1 = vec[0].Nelements;
+	} else {
+	  if ((I >= vec[0].Nelements) || (I < -1*vec[0].Nelements)) {
+	    gprint (GP_ERR, "vector subscript out of range\n"); 
+	    goto escape;
+	  }
+	  if (I < 0) I += vec[0].Nelements;
+	  f1 = (vec[0].type == OPIHI_FLT) ? vec[0].elements.Flt[I] : vec[0].elements.Int[I];
 	}
-	if (I < 0) I += vec[0].Nelements;
-	f1 = (vec[0].type == OPIHI_FLT) ? vec[0].elements.Flt[I] : vec[0].elements.Int[I];
-      }
-    }
-
+      }
+    }
+
+  skipBuffer:
     free (tmpline);
     if ((int)f1 == f1) 
