Browse Source

modifier const, error message if 'system' fails

pre-master-46
Jim Monte 6 years ago
committed by Holger Vogt
parent
commit
19318929c1
  1. 26
      src/frontend/com_shell.c

26
src/frontend/com_shell.c

@ -1,6 +1,7 @@
/************* /*************
* com_shell.c * com_shell.c
************/ ************/
#include <stdio.h>
#include "ngspice/ngspice.h" #include "ngspice/ngspice.h"
#include "ngspice/wordlist.h" #include "ngspice/wordlist.h"
@ -20,7 +21,7 @@
void void
com_shell(wordlist *wl) com_shell(wordlist *wl)
{ {
char *com, *shell = NULL;
char *shell = NULL;
shell = getenv("SHELL"); shell = getenv("SHELL");
if (shell == NULL) { if (shell == NULL) {
@ -39,8 +40,9 @@ com_shell(wordlist *wl)
execl(shell, shell, 0); execl(shell, shell, 0);
_exit(99); _exit(99);
} else { } else {
com = wl_flatten(wl);
char * const com = wl_flatten(wl);
execl("/bin/sh", "sh", "-c", com, 0); execl("/bin/sh", "sh", "-c", com, 0);
txfree(com);
} }
} else { } else {
/* XXX Better have all these signals */ /* XXX Better have all these signals */
@ -58,12 +60,20 @@ com_shell(wordlist *wl)
#else #else
/* Easier to forget about changing the io descriptors. */ /* Easier to forget about changing the io descriptors. */
if (wl) { if (wl) {
com = wl_flatten(wl);
system(com);
tfree(com);
} else {
system(shell);
char * const com = wl_flatten(wl);
if (system(com) == -1) {
(void) fprintf(cp_err, "Unable to execute \"%s\".\n", com);
}
txfree(com);
}
else {
if (system(shell) == -1) {
(void) fprintf(cp_err, "Unable to execute \"%s\".\n", shell);
}
} }
#endif #endif
}
} /* end of function com_shell */
Loading…
Cancel
Save