* Pass the specified command to a shell to be executed. * Like plain "system()", but handles resetting terminal modes, etc. */
(cmd, donemsg)
| 36 | * Like plain "system()", but handles resetting terminal modes, etc. |
| 37 | */ |
| 38 | public void |
| 39 | lsystem(cmd, donemsg) |
| 40 | char *cmd; |
| 41 | char *donemsg; |
| 42 | { |
| 43 | int inp; |
| 44 | #if HAVE_SHELL |
| 45 | char *shell; |
| 46 | char *p; |
| 47 | #endif |
| 48 | IFILE save_ifile; |
| 49 | #if MSDOS_COMPILER && MSDOS_COMPILER!=WIN32C |
| 50 | char cwd[FILENAME_MAX+1]; |
| 51 | #endif |
| 52 | |
| 53 | /* |
| 54 | * Print the command which is to be executed, |
| 55 | * unless the command starts with a "-". |
| 56 | */ |
| 57 | if (cmd[0] == '-') |
| 58 | cmd++; |
| 59 | else |
| 60 | { |
| 61 | clear_bot(); |
| 62 | putstr("!"); |
| 63 | putstr(cmd); |
| 64 | putstr("\n"); |
| 65 | } |
| 66 | |
| 67 | #if MSDOS_COMPILER |
| 68 | #if MSDOS_COMPILER==WIN32C |
| 69 | if (*cmd == '\0') |
| 70 | cmd = getenv("COMSPEC"); |
| 71 | #else |
| 72 | /* |
| 73 | * Working directory is global on MSDOS. |
| 74 | * The child might change the working directory, so we |
| 75 | * must save and restore CWD across calls to "system", |
| 76 | * or else we won't find our file when we return and |
| 77 | * try to "reedit_ifile" it. |
| 78 | */ |
| 79 | getcwd(cwd, FILENAME_MAX); |
| 80 | #endif |
| 81 | #endif |
| 82 | |
| 83 | /* |
| 84 | * Close the current input file. |
| 85 | */ |
| 86 | save_ifile = save_curr_ifile(); |
| 87 | (void) edit_ifile(NULL_IFILE); |
| 88 | |
| 89 | /* |
| 90 | * De-initialize the terminal and take out of raw mode. |
| 91 | */ |
| 92 | deinit(); |
| 93 | flush(); /* Make sure the deinit chars get out */ |
| 94 | raw_mode(0); |
| 95 | #if MSDOS_COMPILER==WIN32C |
no test coverage detected
searching dependent graphs…