Changeset 81bc309 in mainline for uspace/app/bdsh/input.c
- Timestamp:
- 2011-08-20T17:03:29Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c8f70eb
- Parents:
- c916dfc
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/input.c
rc916dfc r81bc309 193 193 } 194 194 195 if (str_cmp(cmd[0], "batch") == 0 && cmd[1] != NULL) { 196 FILE *batch = fopen(cmd[1], "r"); 197 if (batch == NULL) { 198 printf("Cannot open file %s\n", cmd[1]); 199 rc = errno; 200 } else { 201 cliuser_t fusr; 202 fusr.name = usr->name; 203 fusr.cwd = usr->cwd; 204 fusr.prompt = usr->prompt; 205 fusr.line = malloc(INPUT_MAX + 1); 206 char *cur = fusr.line; 207 char *end = fusr.line + INPUT_MAX; 208 int c = fgetc(batch); 209 while (fusr.line != NULL) { 210 if (c == '\n' || c == EOF || cur == end) { 211 *cur = '\0'; 212 if (cur == fusr.line) { 213 /* skip empty line */ 214 rc = 0; 215 free(cur); 216 } else { 217 printf(">%s\n", fusr.line); 218 rc = process_input(&fusr); 219 /* fusr->line was freed by process_input() */ 220 } 221 if (rc == 0 && c != EOF) { 222 fusr.line = malloc(INPUT_MAX + 1); 223 cur = fusr.line; 224 end = fusr.line + INPUT_MAX; 225 } else { 226 break; 227 } 228 } else { 229 *cur++ = c; 230 } 231 c = fgetc(batch); 232 } 233 fclose(batch); 234 } 235 } else { 236 rc = run_command(cmd, usr, &new_iostate); 237 } 195 rc = run_command(cmd, usr, &new_iostate); 238 196 239 197 finit_with_files:
Note:
See TracChangeset
for help on using the changeset viewer.