Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/input.c

    r10f4b47c r9be9c4d  
    169169                new_iostate.stdout = to;
    170170        }
    171 
    172         if (str_cmp(actual_cmd[0], "batch") == 0 && actual_cmd[1] != NULL) {
    173                 FILE *batch = fopen(actual_cmd[1], "r");
    174                 if (batch == NULL) {
    175                         printf("Cannot open file %s\n", actual_cmd[1]);
    176                         rc = errno;
    177                 } else {
    178                         cliuser_t fusr;
    179                         fusr.name = usr->name;
    180                         fusr.cwd = usr->cwd;
    181                         fusr.prompt = usr->prompt;
    182                         fusr.line = malloc(INPUT_MAX + 1);
    183                         char *cur = fusr.line;
    184                         char *end = fusr.line + INPUT_MAX;
    185                         int c = fgetc(batch);
    186                         while (fusr.line != NULL) {
    187                                 if (c == '\n' || c == EOF || cur == end) {
    188                                         *cur = '\0';
    189                                         if (cur == fusr.line) {
    190                                                 /* skip empty line */
    191                                                 rc = 0;
    192                                                 free(cur);
    193                                         } else {
    194                                                 printf(">%s\n", fusr.line);
    195                                                 rc = process_input(&fusr);
    196                                                 /* fusr->line was freed by process_input() */
    197                                         }
    198                                         if (rc == 0 && c != EOF) {
    199                                                 fusr.line = malloc(INPUT_MAX + 1);
    200                                                 cur = fusr.line;
    201                                                 end = fusr.line + INPUT_MAX;
    202                                         } else {
    203                                                 break;
    204                                         }
    205                                 } else {
    206                                         *cur++ = c;
    207                                 }
    208                                 c = fgetc(batch);
    209                         }
    210                         fclose(batch);
    211                 }
    212         } else {
    213                 rc = run_command(actual_cmd, usr, &new_iostate);
    214         }       
     171       
     172        rc = run_command(cmd, usr, &new_iostate);
    215173       
    216174finit_with_files:
Note: See TracChangeset for help on using the changeset viewer.