Changeset b640738 in mainline
- Timestamp:
- 2021-08-18T22:12:33Z (4 years ago)
- Children:
- 12f5a1be
- Parents:
- d6a9824
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/input.c
rd6a9824 rb640738 200 200 pipe_pos[pipe_count++] = i; 201 201 cmd_argc = i; 202 redir_ to = tmpnam(NULL);202 redir_from = redir_to = tmpnam(NULL); 203 203 break; 204 204 … … 251 251 FILE *to = NULL; 252 252 253 if (redir_from) {254 from = fopen(redir_from, "r");255 if (from == NULL) {256 printf("Cannot open file %s\n", redir_from);257 rc = errno;258 goto finit_with_files;259 }260 new_iostate.stdin = from;261 }262 263 if (redir_to) {264 to = fopen(redir_to, "w");265 if (to == NULL) {266 printf("Cannot open file %s\n", redir_to);267 rc = errno;268 goto finit_with_files;269 }270 new_iostate.stdout = to;271 }272 253 273 254 for (unsigned p = 0; p <= pipe_count; p++) { … … 302 283 } 303 284 304 if (p < pipe_count) { 305 new_iostate.stdout = to; 306 } 307 if (p && p == pipe_count) { 308 fseek(to, 0, SEEK_SET); 309 new_iostate.stdin = to; 285 if (redir_to) { 286 if ((p < pipe_count) || (pipe_count == 0)) { 287 to = fopen(redir_to, "w"); 288 if (to == NULL) { 289 printf( 290 "Cannot open file %s redirect to\n", 291 redir_to); 292 rc = errno; 293 goto finit_with_files; 294 } 295 new_iostate.stdout = to; 296 } 297 } 298 299 if (redir_from) { 300 if ((p && p == pipe_count) || (pipe_count == 0)) { 301 from = fopen(redir_from, "r"); 302 if (from == NULL) { 303 printf("Cannot open file %s redirect " 304 "from\n", 305 redir_from); 306 rc = errno; 307 goto finit_with_files; 308 } 309 new_iostate.stdin = from; 310 } 310 311 } 311 312 … … 316 317 } 317 318 319 if (to) { 320 fclose(to); 321 to = NULL; 322 } 323 if (from) { 324 fclose(from); 325 from = NULL; 326 } 318 327 // Restore the Standard Input, Output and Error file descriptors 319 328 new_iostate.stdin = stdin;
Note:
See TracChangeset
for help on using the changeset viewer.