dcc1ce202a76ae34567a597feebb216f390e3bb0
kent
  Mon Jan 11 18:05:57 2021 -0800
Improved usage and explicitly fv->type - good ideas from Jonathan's code review ref #26745

diff --git src/tabFile/tabToTabDir/tabToTabDir.c src/tabFile/tabToTabDir/tabToTabDir.c
index 3f10336..19d48d7 100644
--- src/tabFile/tabToTabDir/tabToTabDir.c
+++ src/tabFile/tabToTabDir/tabToTabDir.c
@@ -19,39 +19,39 @@
 void usage()
 /* Explain usage and exit. */
 {
 errAbort(
 "tabToTabDir - Convert a large tab-separated table to a directory full of such tables according\n"
 "to a specification. The program is designed to make it relatively easy to unpack overloaded\n"
 "single fields into multiple fields, and to created normalized less redundant representations.\n"
 "The command line is:\n"
 "   tabToTabDir in.tsv spec.x outDir\n"
 "options:\n"
 "   -id=fieldName - Add a numeric id field of given name that starts at 1 and autoincrements \n"
 "                   for each table\n"
 "   -startId=fieldName - sets starting ID to be something other than 1\n"
 "usage:\n"
 "   in.tsv is a tab-separated input file.  The first line is the label names and may start with #\n"
-"   spec.txt is a file that says what columns to put into the output, described in more detail below.\n"
+"   spec.x is a file that says what columns to put into the output, described in more detail below.\n"
 "The spec.x file contains one blank line separated stanza per output table.\n"
 "Each stanza should look like:\n"
 "        table tableName    key-column\n"
 "        columnName1	sourceExpression1\n"
 "        columnName2	sourceExpression2\n"
 "              ...\n"
 "if the sourceExpression is missing it is assumed to be a just a field of the same name from in.tsv\n"
-"Otherwise the sourceField can be a strex expression involving fields in in.tsv.\n"
+"Otherwise the sourceExpression can be a strex expression involving fields in in.tsv.\n"
 "\n"
 "Each output table has duplicate rows merged using the key-column to determine uniqueness.\n"
 "Please see tabToTabDir.doc in the source code for more information on what can go into spec.x.\n"
 );
 }
 
 /* Command line validation table. */
 static struct optionSpec options[] = {
    {"id", OPTION_STRING},
    {"startId", OPTION_INT},
    {NULL, 0},
 };
 
 
 enum fieldValType
@@ -191,30 +191,31 @@
 if (c == '?')
     {
     fv->optional = TRUE;
     name += 1;
     }
 else if (!isalpha(c) && (c != '_'))
     {
     errAbort("Strange character %c starting line %d of %s", c, fileLineNumber, fileName);
     }
 fv->name = cloneString(name);
 
 char *s = trimSpaces(input);
 if (isEmpty(s))
     {
     s = cloneString(name);
+    fv->type = fvVar;
     }
 c = s[0];
 if (c == '@')
     {
     char *val = fv->val = cloneString(skipLeadingSpaces(s+1));
     if (isEmpty(val))
 	errAbort("Nothing following %c line %d of %s", c, fileLineNumber, fileName);
     fv->type = fvLink;
     ++gLinkFields;
     }
 else 
     {
     if (c == '$')
 	{
 	char *command = skipLeadingSpaces(s+1);