annotate src/vimrun.c @ 7224:42bf8902d4da v7.4.921

commit https://github.com/vim/vim/commit/cd1c55f706c2f9b8310b8a9fc1f8226c7fd19372 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Nov 10 20:52:04 2015 +0100 patch 7.4.921 Problem: Missing proto file update. (Randall W. Morris) Solution: Add the missing line for mch_ishidden.
author Christian Brabandt <cb@256bit.org>
date Tue, 10 Nov 2015 21:00:05 +0100
parents fbec41e5651e
children da7307987ed1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 /* vi:set ts=8 sts=4 sw=4:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 * VIM - Vi IMproved by Bram Moolenaar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 * this file by Vince Negri
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 * Do ":help uganda" in Vim to read copying and usage conditions.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 * Do ":help credits" in Vim to see a list of people who contributed.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
8 * See README.txt for an overview of the Vim source code.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
9 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 * vimrun.c - Tiny Win32 program to safely run an external command in a
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 * DOS console.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 * This program is required to avoid that typing CTRL-C in the DOS
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15 * console kills Vim. Now it only kills vimrun.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18 #include <stdio.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 #include <stdlib.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 #ifndef __CYGWIN__
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 # include <conio.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 #ifdef __BORLANDC__
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 extern char *
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 #ifdef _RTLDLL
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 __import
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 _oscmd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 # define _kbhit kbhit
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 # define _getch getch
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 # ifdef __MINGW32__
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 # ifndef WIN32_LEAN_AND_MEAN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 # define WIN32_LEAN_AND_MEAN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 # include <windows.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 # ifdef __CYGWIN__
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 # ifndef WIN32_LEAN_AND_MEAN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 # define WIN32_LEAN_AND_MEAN
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 # include <windows.h>
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
44 # define _getch getchar
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 extern char *_acmdln;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
49 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 int
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 main(void)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 const char *p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 int retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 int inquote = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 int silent = 0;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
58
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 #ifdef __BORLANDC__
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 p = _oscmd;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 #else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 # if defined(__MINGW32__) || defined(__CYGWIN__)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
63 p = (const char *)GetCommandLine();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 # else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 p = _acmdln;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 # endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
67 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 * Skip the executable name, which might be in "".
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 while (*p)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 if (*p == '"')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 inquote = !inquote;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 else if (!inquote && *p == ' ')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 break;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 }
7166
fbec41e5651e commit https://github.com/vim/vim/commit/f59c73da1e8eb16e7b49b4465aedd1d6ddacc6fd
Christian Brabandt <cb@256bit.org>
parents: 1121
diff changeset
82 while (*p == ' ')
fbec41e5651e commit https://github.com/vim/vim/commit/f59c73da1e8eb16e7b49b4465aedd1d6ddacc6fd
Christian Brabandt <cb@256bit.org>
parents: 1121
diff changeset
83 ++p;
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
85 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 * "-s" argument: don't wait for a key hit.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 if (p[0] == '-' && p[1] == 's' && p[2] == ' ')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 silent = 1;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 p += 3;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92 while (*p == ' ')
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 ++p;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 /* Print the command, including quotes and redirection. */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
97 puts(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 /*
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 * Do it!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 */
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
102 retval = system(p);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103
1121
e63691e7c504 updated for version 7.1a
vimboss
parents: 7
diff changeset
104 if (retval == -1)
e63691e7c504 updated for version 7.1a
vimboss
parents: 7
diff changeset
105 perror("vimrun system(): ");
e63691e7c504 updated for version 7.1a
vimboss
parents: 7
diff changeset
106 else if (retval != 0)
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 printf("shell returned %d\n", retval);
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 if (!silent)
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 {
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 puts("Hit any key to close this window...");
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 #ifndef __CYGWIN__
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 while (_kbhit())
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 (void)_getch();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 #endif
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 (void)_getch();
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 }
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 return retval;
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 }