Changeset 10f4b47c in mainline
- Timestamp:
- 2011-07-24T17:44:44Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1e891d0
- Parents:
- e76e833
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/input.c
re76e833 r10f4b47c 169 169 new_iostate.stdout = to; 170 170 } 171 172 rc = run_command(cmd, usr, &new_iostate); 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 } 173 215 174 216 finit_with_files:
Note:
See TracChangeset
for help on using the changeset viewer.