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
4 #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
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
11 #define BUILTIN_FLAG_SPECIAL 0x01
12 #define BUILTIN_FLAG_ASSIGNMENT 0x02
13 +#define BUILTIN_FLAG_REQUIRES 0x04
15 /* If this stream descriptor is non-zero, then write
16 texinfo documentation to it. */
21 +/* The builtin commands that cause requirements on other files. */
22 +char *requires_builtins[] =
24 + ".", "command", "exec", "source", "inlib",
28 /* Forward declarations. */
29 static int is_special_builtin ();
30 static int is_assignment_builtin ();
31 +static int is_requires_builtin ();
33 #if !defined (HAVE_RENAME)
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;
42 array_add ((char *)new, defs->builtins);
44 @@ -1164,10 +1179,11 @@
46 fprintf (structfile, "(sh_builtin_func_t *)0x0, ");
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 document_name (builtin));
57 @@ -1401,6 +1417,13 @@
60 return (_find_in_table (name, assignment_builtins));
64 +is_requires_builtin (name)
67 + return (_find_in_table (name, requires_builtins));
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
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.
84 Equivalent to \fB\-v\fP.
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 @@
90 Make the shell a restricted shell (@pxref{The Restricted Shell}).
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.
100 Equivalent to @samp{-v}. Print shell input lines as they're read.
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
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. */
110 /* The thing that we build the array of builtins out of. */
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
118 +#include "builtins.h"
120 +#include "builtins/common.h"
122 #if defined (JOB_CONTROL)
126 extern int line_number, current_command_line_count;
127 extern int last_command_exit_value;
128 +extern int rpm_requires;
129 +char *alphabet_set = "abcdefghijklmnopqrstuvwxyz"
130 + "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
132 static COMMAND *make_for_or_select __P((enum command_type, WORD_DESC *, WORD_LIST *, COMMAND *));
133 #if defined (ARITH_FOR_COMMAND)
135 return (make_command (cm_subshell, (SIMPLE_COM *)temp));
139 +output_requirement (file)
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.*/
147 + basename = strrchr(file, '/');
155 + if the executable is called via variable substitution we can
156 + not dermine what it is at compile time.
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}").
163 + if ( !strchr(file, '$') && strpbrk(file, alphabet_set) ) {
164 + printf ("executable(%s)\n", file);
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. */
172 command->value.Simple->redirects =
173 REVERSE_LIST (command->value.Simple->redirects, REDIRECT *);
176 + if (rpm_requires && command->value.Simple->words)
182 + cmd0 = command->value.Simple->words->word->word;
183 + b = builtin_address_internal (cmd0, 0);
185 + if (command->value.Simple->words->next) {
186 + cmd1 = command->value.Simple->words->next->word->word;
189 + if ( (b->flags & REQUIRES_BUILTIN) && cmd1){
190 + output_requirement(cmd1);
193 + if (!assignment(cmd0, 0)) {
194 + output_requirement(cmd0);
197 + /* This will not work, the subshell that this runs in does
198 + not get the "requires" commandline argument. */
200 + execute_command(command);
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
210 /* The name of the .(shell)rc file. */
211 static char *bashrc_file = "~/.bashrc";
213 +/* Non-zero if we are finding the scripts requirements. */
216 /* Non-zero means to act more like the Bourne shell on startup. */
217 static int act_like_sh;
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 },
229 if (dump_translatable_strings)
230 read_but_dont_execute = 1;
234 + read_but_dont_execute = 1;
235 + initialize_shell_builtins ();
238 if (running_setuid && privileged_mode == 0)
239 disable_priv_mode ();