]> git.pld-linux.org Git - packages/bash.git/blame - bash-requires.patch
- ipv6 support is back
[packages/bash.git] / bash-requires.patch
CommitLineData
35373510 1--- bash-2.04-beta5/builtins/mkbuiltins.c.requires Thu Aug 5 12:42:54 1999
2+++ bash-2.04-beta5/builtins/mkbuiltins.c Sun Mar 19 14:14:17 2000
3@@ -51,8 +51,13 @@
4 #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
5
6 /* Flag values that builtins can have. */
7+/* These flags are for the C code generator,
8+ the C which is produced (./builtin.c)
9+ includes the flags definitions found
10+ in ../builtins.h */
11 #define BUILTIN_FLAG_SPECIAL 0x01
12 #define BUILTIN_FLAG_ASSIGNMENT 0x02
13+#define BUILTIN_FLAG_REQUIRES 0x04
14
15 /* If this stream descriptor is non-zero, then write
16 texinfo documentation to it. */
17@@ -126,9 +131,17 @@
18 (char *)NULL
19 };
20
21+/* The builtin commands that cause requirements on other files. */
22+char *requires_builtins[] =
23+{
24+ ".", "command", "exec", "source", "inlib",
25+ (char *)NULL
26+};
27+
28 /* Forward declarations. */
29 static int is_special_builtin ();
30 static int is_assignment_builtin ();
31+static int is_requires_builtin ();
32
33 #if !defined (HAVE_RENAME)
34 static int rename ();
35@@ -759,6 +772,8 @@
36 new->flags |= BUILTIN_FLAG_SPECIAL;
37 if (is_assignment_builtin (name))
38 new->flags |= BUILTIN_FLAG_ASSIGNMENT;
39+ if (is_requires_builtin (name))
40+ new->flags |= BUILTIN_FLAG_REQUIRES;
41
42 array_add ((char *)new, defs->builtins);
43 building_builtin = 1;
44@@ -1164,10 +1179,11 @@
45 else
46 fprintf (structfile, "(Function *)0x0, ");
47
48- fprintf (structfile, "%s%s%s, %s_doc,\n",
49+ fprintf (structfile, "%s%s%s%s, %s_doc,\n",
50 "BUILTIN_ENABLED | STATIC_BUILTIN",
51 (builtin->flags & BUILTIN_FLAG_SPECIAL) ? " | SPECIAL_BUILTIN" : "",
52 (builtin->flags & BUILTIN_FLAG_ASSIGNMENT) ? " | ASSIGNMENT_BUILTIN" : "",
53+ (builtin->flags & BUILTIN_FLAG_REQUIRES) ? " | REQUIRES_BUILTIN" : "",
54 builtin->docname ? builtin->docname : builtin->name);
55
56 fprintf
57@@ -1401,6 +1417,13 @@
58 char *name;
59 {
60 return (_find_in_table (name, assignment_builtins));
61+}
62+
63+static int
64+is_requires_builtin (name)
65+ char *name;
66+{
67+ return (_find_in_table (name, requires_builtins));
68 }
69
70 #if !defined (HAVE_RENAME)
71--- bash-2.04-beta5/doc/bash.1.requires Tue Jan 11 19:36:49 2000
72+++ bash-2.04-beta5/doc/bash.1 Sun Mar 19 14:14:17 2000
73@@ -196,6 +196,12 @@
74 .B "RESTRICTED SHELL"
75 below).
76 .TP
77+.B \-\-rpm-requires
78+Produce the list of files that are required for the
79+shell script to run. This implies '-n' and is subject
80+to the same limitations as compile time error checking checking;
81+Backticks, [] tests, and evals are not parsed so some
82+dependencies may be missed.
83 .B \-\-verbose
84 Equivalent to \fB\-v\fP.
85 .TP
86--- bash-2.04-beta5/doc/bashref.texi.requires Wed Jan 12 16:18:50 2000
87+++ bash-2.04-beta5/doc/bashref.texi Sun Mar 19 14:14:17 2000
88@@ -4333,6 +4333,13 @@
89 @item --restricted
90 Make the shell a restricted shell (@pxref{The Restricted Shell}).
91
92+@item --rpm-requires
93+Produce the list of files that are required for the
94+shell script to run. This implies '-n' and is subject
95+to the same limitations as compile time error checking checking;
96+Backticks, [] tests, and evals are not parsed so some
97+dependencies may be missed.
98+
99 @item --verbose
100 Equivalent to @samp{-v}. Print shell input lines as they're read.
101
102--- bash-2.04-beta5/builtins.h.requires Thu Aug 5 11:18:12 1999
103+++ bash-2.04-beta5/builtins.h Sun Mar 19 14:14:17 2000
104@@ -40,6 +40,7 @@
105 #define STATIC_BUILTIN 0x4 /* This builtin is not dynamically loaded. */
106 #define SPECIAL_BUILTIN 0x8 /* This is a Posix `special' builtin. */
107 #define ASSIGNMENT_BUILTIN 0x10 /* This builtin takes assignment statements. */
108+#define REQUIRES_BUILTIN 0x20 /* This builtin requires other files. */
109
110 /* The thing that we build the array of builtins out of. */
111 struct builtin {
112--- bash-2.04-beta5/make_cmd.c.requires Thu Aug 5 11:21:23 1999
113+++ bash-2.04-beta5/make_cmd.c Sun Mar 19 14:17:34 2000
114@@ -41,6 +41,9 @@
115 #include "subst.h"
116 #include "input.h"
117 #include "externs.h"
118+#include "builtins.h"
119+
120+#include "builtins/common.h"
121
122 #if defined (JOB_CONTROL)
123 #include "jobs.h"
124@@ -49,7 +52,10 @@
125 extern int line_number, current_command_line_count;
126 extern int disallow_filename_globbing;
127 extern int last_command_exit_value;
128+extern int rpm_requires;
129
130+char *alphabet_set = "abcdefghijklmnopqrstuvwxyz"
131+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
132
133 WORD_DESC *
134 make_bare_word (string)
135@@ -696,6 +702,36 @@
136 return (make_command (cm_subshell, (SIMPLE_COM *)temp));
137 }
138
139+void
140+output_requirement (file)
141+char *file;
142+{
143+ if ( (file[0] != '/') || strchr(file, '$')) {
144+ /* if we are not given a full path name we require the basename
145+ otherwise we require the full path. This does not work in the
146+ Win/Dos world but I don't know what to do there.*/
147+ char *basename;
148+ basename = strrchr(file, '/');
149+ if (basename) {
150+ basename++;
151+ file=basename;
152+ }
153+ }
154+
155+ /*
156+ if the executable is called via variable substitution we can
157+ not dermine what it is at compile time.
158+
159+ if the executable consists only of characters not in the
160+ alphabet we do not consider it a dependency just an artifact of
161+ shell parsing (ex "exec < ${infile}").
162+ */
163+
164+ if ( !strchr(file, '$') && strpbrk(file, alphabet_set) ) {
165+ printf ("executable(%s)\n", file);
166+ }
167+}
168+
169 /* Reverse the word list and redirection list in the simple command
170 has just been parsed. It seems simpler to do this here the one
171 time then by any other method that I can think of. */
172@@ -712,6 +748,35 @@
173 command->value.Simple->redirects =
174 REVERSE_LIST (command->value.Simple->redirects, REDIRECT *);
175 }
176+
177+ if (rpm_requires && command->value.Simple->words)
178+ {
179+ char *cmd0;
180+ char *cmd1;
181+ struct builtin *b;
182+
183+ cmd0 = command->value.Simple->words->word->word;
184+ b = builtin_address_internal (cmd0, 0);
185+ cmd1 = 0;
186+ if (command->value.Simple->words->next) {
187+ cmd1 = command->value.Simple->words->next->word->word;
188+ }
189+ if (b) {
190+ if ( (b->flags & REQUIRES_BUILTIN) && cmd1){
191+ output_requirement(cmd1);
192+ }
193+ } else {
194+ if (!assignment(cmd0)) {
195+ output_requirement(cmd0);
196+ } else {
197+
198+ /* This will not work, the subshell that this runs in does
199+ not get the "requires" commandline argument. */
200+
201+ execute_command(command);
202+ }
203+ }
204+ } /*rpm_requires*/
205
206 return (command);
207 }
208--- bash-2.04-beta5/shell.c.requires Fri Nov 19 19:58:15 1999
209+++ bash-2.04-beta5/shell.c Sun Mar 19 14:14:17 2000
210@@ -163,6 +163,9 @@
211 /* The name of the .(shell)rc file. */
212 static char *bashrc_file = "~/.bashrc";
213
214+/* Non-zero if we are finding the scripts requirements. */
215+int rpm_requires;
216+
217 /* Non-zero means to act more like the Bourne shell on startup. */
218 static int act_like_sh;
219
220@@ -208,6 +211,7 @@
221 { "norc", Int, &no_rc, (char **)0x0 },
222 { "posix", Int, &posixly_correct, (char **)0x0 },
223 { "rcfile", Charp, (int *)0x0, &bashrc_file },
224+ { "rpm-requires", Int, &rpm_requires, (char **)0x0 },
225 #if defined (RESTRICTED_SHELL)
226 { "restricted", Int, &restricted, (char **)0x0 },
227 #endif
228@@ -393,6 +397,12 @@
229
230 if (dump_translatable_strings)
231 read_but_dont_execute = 1;
232+
233+ if (rpm_requires)
234+ {
235+ read_but_dont_execute = 1;
236+ initialize_shell_builtins ();
237+ }
238
239 if (running_setuid && privileged_mode == 0)
240 disable_priv_mode ();
This page took 0.09092 seconds and 4 git commands to generate.