IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Dec 20, 2010, 8:36:52 AM (16 years ago)
Author:
eugene
Message:

handle syntax errors in ohana scripts as errors

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20101205/Ohana/src/opihi/lib.shell/command.c

    r30081 r30115  
    1010  Command *cmd;
    1111
    12   // rawline = NULL;
     12  // the input line is never NULL
     13  if (!line) { fprintf (stderr, "programming error\n"); abort(); }
     14
    1315  rawline = strcreate (line);
    1416
     
    2022  }
    2123
    22  XXX: check for NULL return from expand_* and raise error
    23 
    2424  /* expand anything of the form $fred or $fred$sam, etc */
    2525  line = expand_vars (line);     /* line is freed here, new one allocated */
     26  if (!line) goto escape;
     27
    2628  /* expand anything of the form fred[N] */
    2729  line = expand_vectors (line);  /* line is freed here, new one allocated */
     30  if (!line) goto escape;
    2831
    2932  // print the line with the variables and vectors expanded, but before evaluating
     
    3134  if (VERBOSE_SHELL == OPIHI_VERBOSE_ON) gprint (GP_ERR, "opihi: %s\n", line);
    3235
    33   /* solve math expresions, assign variable, if needed */
    34   line = parse (line);        /* line is freed here, new one allocated */
    35   /* any entry in line of the form {foo} returns value or tmp vector / buffer */
     36  /* solve math expresions, assign variable, if needed.  any entry in line of the form {foo}
     37   * returns value or tmp vector / buffer */
     38  line = parse (&status, line);        /* line is freed here, new one allocated */
     39  if (!status) goto escape;
    3640
    3741  /* we may have reallocated line, return new pointer */
     
    4145  if (argc == 0) {
    4246      FREE (rawline);
     47      set_int_variable ("STATUS", TRUE);
    4348      return (TRUE);  /* empty command or assignment */
    4449  }
     
    7681  FREE (rawline);
    7782  return (status);
     83
     84 escape:
     85  set_int_variable ("STATUS", FALSE);
     86
     87  # if (DEBUG)
     88  gprint (GP_ERR, "command: %s, status: %d\n", line, FALSE);
     89  # endif
     90
     91  FREE (rawline);
     92  return FALSE;
    7893}
    7994
Note: See TracChangeset for help on using the changeset viewer.