1 /* $Id: shell.c,v 1.2 2001/02/18 17:07:27 amura Exp $ */
2 /*
3 * Shell commands.
4 * The file contains the command
5 * processor, shell-command
6 * written by Kaoru Maeda.
7 */
8
9 /*
10 * $Log: shell.c,v $
11 * Revision 1.2 2001/02/18 17:07:27 amura
12 * append AUTOSAVE feature (but NOW not work)
13 *
14 * Revision 1.1.1.1 2000/06/27 01:47:56 amura
15 * import to CVS
16 *
17 */
18
19 #include "config.h" /* 91.01.10 by S.Yoshida */
20 #include "def.h"
21
22 #ifndef NO_SHELL
23 /*ARGSUSED*/
shellcmnd(f,n)24 shellcmnd(f, n)
25 {
26 char buf[CMDLINELENGTH];
27 char *result;
28 extern char *call_process();
29 extern int isetmark(),gotobob();
30 int s;
31 BUFFER *bp, *obp;
32 WINDOW *wp, *owp;
33 WINDOW *popbuf();
34
35 s = ereply("Shell command: ", buf, sizeof buf);
36 if (s != TRUE)
37 return s;
38 if ((f & FFARG) == 0) {
39 if ((bp = bfind("*Shell Command Output*", TRUE)) == NULL) return FALSE;
40 if ((wp = popbuf(bp)) == NULL) return FALSE;
41 bp->b_flag &= ~BFCHG; /* Blow away old. */
42 if (bclear(bp) != TRUE) return FALSE;
43 obp = curbp; owp = curwp;
44 curbp = bp; curwp = wp;
45 }
46 if ((result = call_process(buf, NULL)) == NULL)
47 return FALSE;
48 isetmark();
49 ewprintf(result);
50 s = insertfile(result, (char *)NULL);
51 if((f & FFARG) == 0) {
52 (VOID) gotobob(0, 1);
53 bp->b_dotp = wp->w_dotp;
54 bp->b_doto = wp->w_doto;
55 curbp = obp;
56 curwp = owp;
57 #ifdef AUTOSAVE /* 96.12.24 by M.Suzuki */
58 bp->b_flag &= ~(BFCHG | BFACHG);
59 #else
60 bp->b_flag &= ~BFCHG;
61 #endif /* AUTOSAVE */
62 }
63 unlink(result);
64 return s;
65 }
66 #endif
67