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 BUILTIN_FLAG_SPECIAL 0x01
5 #define BUILTIN_FLAG_ASSIGNMENT 0x02
6 #define BUILTIN_FLAG_POSIX_BUILTIN 0x04
7 +#define BUILTIN_FLAG_REQUIRES 0x08
15 +/* The builtin commands that cause requirements on other files. */
16 +char *requires_builtins[] =
18 + ".", "command", "exec", "source", "inlib",
22 /* Forward declarations. */
23 static int is_special_builtin ();
24 static int is_assignment_builtin ();
25 static int is_posix_builtin ();
26 +static int is_requires_builtin ();
28 #if !defined (HAVE_RENAME)
31 new->flags |= BUILTIN_FLAG_ASSIGNMENT;
32 if (is_posix_builtin (name))
33 new->flags |= BUILTIN_FLAG_POSIX_BUILTIN;
34 + if (is_requires_builtin (name))
35 + new->flags |= BUILTIN_FLAG_REQUIRES;
37 array_add ((char *)new, defs->builtins);
39 @@ -1240,11 +1240,12 @@
41 fprintf (structfile, "(sh_builtin_func_t *)0x0, ");
43 - fprintf (structfile, "%s%s%s%s, %s_doc,\n",
44 + fprintf (structfile, "%s%s%s%s%s, %s_doc,\n",
45 "BUILTIN_ENABLED | STATIC_BUILTIN",
46 (builtin->flags & BUILTIN_FLAG_SPECIAL) ? " | SPECIAL_BUILTIN" : "",
47 (builtin->flags & BUILTIN_FLAG_ASSIGNMENT) ? " | ASSIGNMENT_BUILTIN" : "",
48 (builtin->flags & BUILTIN_FLAG_POSIX_BUILTIN) ? " | POSIX_BUILTIN" : "",
49 + (builtin->flags & BUILTIN_FLAG_REQUIRES) ? " | REQUIRES_BUILTIN" : "",
50 document_name (builtin));
53 @@ -1401,6 +1417,13 @@
56 return (_find_in_table (name, assignment_builtins));
60 +is_requires_builtin (name)
63 + return (_find_in_table (name, requires_builtins));
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
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.
80 Equivalent to \fB\-v\fP.
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 @@
86 Make the shell a restricted shell (@pxref{The Restricted Shell}).
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.
96 Equivalent to @samp{-v}. Print shell input lines as they're read.
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
101 #define SPECIAL_BUILTIN 0x08 /* This is a Posix `special' builtin. */
102 #define ASSIGNMENT_BUILTIN 0x10 /* This builtin takes assignment statements. */
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. */
106 #define BASE_INDENT 4
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
114 +#include "builtins.h"
116 +#include "builtins/common.h"
118 #if defined (JOB_CONTROL)
122 extern int line_number, current_command_line_count;
123 extern int last_command_exit_value;
124 +extern int rpm_requires;
125 +char *alphabet_set = "abcdefghijklmnopqrstuvwxyz"
126 + "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
128 static COMMAND *make_for_or_select __P((enum command_type, WORD_DESC *, WORD_LIST *, COMMAND *));
129 #if defined (ARITH_FOR_COMMAND)
131 return (make_command (cm_subshell, (SIMPLE_COM *)temp));
135 +output_requirement (file)
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.*/
143 + basename = strrchr(file, '/');
151 + if the executable is called via variable substitution we can
152 + not dermine what it is at compile time.
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}").
159 + if ( !strchr(file, '$') && strpbrk(file, alphabet_set) ) {
160 + printf ("executable(%s)\n", file);
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. */
168 command->value.Simple->redirects =
169 REVERSE_LIST (command->value.Simple->redirects, REDIRECT *);
172 + if (rpm_requires && command->value.Simple->words)
178 + cmd0 = command->value.Simple->words->word->word;
179 + b = builtin_address_internal (cmd0, 0);
181 + if (command->value.Simple->words->next) {
182 + cmd1 = command->value.Simple->words->next->word->word;
185 + if ( (b->flags & REQUIRES_BUILTIN) && cmd1){
186 + output_requirement(cmd1);
189 + if (!assignment(cmd0, 0)) {
190 + output_requirement(cmd0);
193 + /* This will not work, the subshell that this runs in does
194 + not get the "requires" commandline argument. */
196 + execute_command(command);
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
206 /* The name of the .(shell)rc file. */
207 static char *bashrc_file = "~/.bashrc";
209 +/* Non-zero if we are finding the scripts requirements. */
212 /* Non-zero means to act more like the Bourne shell on startup. */
213 static int act_like_sh;
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 },
225 if (dump_translatable_strings)
226 read_but_dont_execute = 1;
230 + read_but_dont_execute = 1;
231 + initialize_shell_builtins ();
234 if (running_setuid && privileged_mode == 0)
235 disable_priv_mode ();