MCPcopy Create free account
hub / github.com/gwsw/less / lsystem

Function lsystem

lsystem.c:38–234  ·  view source on GitHub ↗

* Pass the specified command to a shell to be executed. * Like plain "system()", but handles resetting terminal modes, etc. */

(cmd, donemsg)

Source from the content-addressed store, hash-verified

36 * Like plain "system()", but handles resetting terminal modes, etc.
37 */
38 public void
39lsystem(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

Callers 2

exec_mcaFunction · 0.85
commandsFunction · 0.85

Calls 15

clear_botFunction · 0.85
putstrFunction · 0.85
save_curr_ifileFunction · 0.85
edit_ifileFunction · 0.85
deinitFunction · 0.85
flushFunction · 0.85
close_getchrFunction · 0.85
init_signalsFunction · 0.85
tty_deviceFunction · 0.85
lgetenvFunction · 0.85
shell_quoteFunction · 0.85
ecallocFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…