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