]> git.pld-linux.org Git - packages/bash.git/blame - bash-requires.patch
- up to 3.2.39
[packages/bash.git] / bash-requires.patch
CommitLineData
69ed6004
JB
1--- bash-2.05b/builtins/mkbuiltins.c.requires Thu Aug 5 12:42:54 1999
2+++ bash-2.05b/builtins/mkbuiltins.c Sun Mar 19 14:14:17 2000
35373510 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
69ed6004 46 fprintf (structfile, "(sh_builtin_func_t *)0x0, ");
35373510 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" : "",
69ed6004 54 document_name (builtin));
35373510 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"
2fce1949 124@@ -49,6 +52,9 @@
125
35373510 126 extern int line_number, current_command_line_count;
35373510 127 extern int last_command_exit_value;
128+extern int rpm_requires;
35373510 129+char *alphabet_set = "abcdefghijklmnopqrstuvwxyz"
130+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
131
2fce1949 132 static COMMAND *make_for_or_select __P((enum command_type, WORD_DESC *, WORD_LIST *, COMMAND *));
133 #if defined (ARITH_FOR_COMMAND)
35373510 134@@ -696,6 +702,36 @@
135 return (make_command (cm_subshell, (SIMPLE_COM *)temp));
136 }
137
138+void
139+output_requirement (file)
140+char *file;
141+{
142+ if ( (file[0] != '/') || strchr(file, '$')) {
143+ /* if we are not given a full path name we require the basename
144+ otherwise we require the full path. This does not work in the
145+ Win/Dos world but I don't know what to do there.*/
146+ char *basename;
147+ basename = strrchr(file, '/');
148+ if (basename) {
149+ basename++;
150+ file=basename;
151+ }
152+ }
153+
154+ /*
155+ if the executable is called via variable substitution we can
156+ not dermine what it is at compile time.
157+
158+ if the executable consists only of characters not in the
159+ alphabet we do not consider it a dependency just an artifact of
160+ shell parsing (ex "exec < ${infile}").
161+ */
162+
163+ if ( !strchr(file, '$') && strpbrk(file, alphabet_set) ) {
164+ printf ("executable(%s)\n", file);
165+ }
166+}
167+
168 /* Reverse the word list and redirection list in the simple command
169 has just been parsed. It seems simpler to do this here the one
170 time then by any other method that I can think of. */
171@@ -712,6 +748,35 @@
172 command->value.Simple->redirects =
173 REVERSE_LIST (command->value.Simple->redirects, REDIRECT *);
174 }
175+
176+ if (rpm_requires && command->value.Simple->words)
177+ {
178+ char *cmd0;
179+ char *cmd1;
180+ struct builtin *b;
181+
182+ cmd0 = command->value.Simple->words->word->word;
183+ b = builtin_address_internal (cmd0, 0);
184+ cmd1 = 0;
185+ if (command->value.Simple->words->next) {
186+ cmd1 = command->value.Simple->words->next->word->word;
187+ }
188+ if (b) {
189+ if ( (b->flags & REQUIRES_BUILTIN) && cmd1){
190+ output_requirement(cmd1);
191+ }
192+ } else {
71ad8a74 193+ if (!assignment(cmd0, 0)) {
35373510 194+ output_requirement(cmd0);
195+ } else {
196+
197+ /* This will not work, the subshell that this runs in does
198+ not get the "requires" commandline argument. */
199+
200+ execute_command(command);
201+ }
202+ }
203+ } /*rpm_requires*/
204
205 return (command);
206 }
207--- bash-2.04-beta5/shell.c.requires Fri Nov 19 19:58:15 1999
208+++ bash-2.04-beta5/shell.c Sun Mar 19 14:14:17 2000
209@@ -163,6 +163,9 @@
210 /* The name of the .(shell)rc file. */
211 static char *bashrc_file = "~/.bashrc";
212
213+/* Non-zero if we are finding the scripts requirements. */
214+int rpm_requires;
215+
216 /* Non-zero means to act more like the Bourne shell on startup. */
217 static int act_like_sh;
218
219@@ -208,6 +211,7 @@
220 { "norc", Int, &no_rc, (char **)0x0 },
221 { "posix", Int, &posixly_correct, (char **)0x0 },
222 { "rcfile", Charp, (int *)0x0, &bashrc_file },
223+ { "rpm-requires", Int, &rpm_requires, (char **)0x0 },
224 #if defined (RESTRICTED_SHELL)
225 { "restricted", Int, &restricted, (char **)0x0 },
226 #endif
227@@ -393,6 +397,12 @@
228
229 if (dump_translatable_strings)
230 read_but_dont_execute = 1;
231+
232+ if (rpm_requires)
233+ {
234+ read_but_dont_execute = 1;
235+ initialize_shell_builtins ();
236+ }
237
238 if (running_setuid && privileged_mode == 0)
239 disable_priv_mode ();
This page took 0.078033 seconds and 4 git commands to generate.