2 Here it is. If you like it let me know and I will send the patches to
3 the bash maintainer. Let me know what you think.
9 diff -r -u bash-2.03.orig/builtins/mkbuiltins.c bash-2.03.new/builtins/mkbuiltins.c
10 --- bash-2.03.orig/builtins/mkbuiltins.c Tue Sep 15 12:57:16 1998
11 +++ bash-2.03.new/builtins/mkbuiltins.c Fri Jul 16 10:45:54 1999
13 #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
15 /* Flag values that builtins can have. */
16 +/* These flags are for the C code generator,
17 + the C which is produced (./builtin.c)
18 + includes the flags definitions found
20 #define BUILTIN_FLAG_SPECIAL 0x01
21 #define BUILTIN_FLAG_ASSIGNMENT 0x02
22 +#define BUILTIN_FLAG_REQUIRES 0x04
24 /* If this stream descriptor is non-zero, then write
25 texinfo documentation to it. */
30 +/* The builtin commands that cause requirements on other files. */
31 +char *requires_builtins[] =
33 + ".", "command", "exec", "source", "inlib",
37 /* Forward declarations. */
38 static int is_special_builtin ();
39 static int is_assignment_builtin ();
40 +static int is_requires_builtin ();
42 #if !defined (HAVE_RENAME)
45 new->flags |= BUILTIN_FLAG_SPECIAL;
46 if (is_assignment_builtin (name))
47 new->flags |= BUILTIN_FLAG_ASSIGNMENT;
48 + if (is_requires_builtin (name))
49 + new->flags |= BUILTIN_FLAG_REQUIRES;
51 array_add ((char *)new, defs->builtins);
53 @@ -1164,10 +1179,11 @@
55 fprintf (structfile, "(Function *)0x0, ");
57 - fprintf (structfile, "%s%s%s, %s_doc,\n",
58 + fprintf (structfile, "%s%s%s%s, %s_doc,\n",
59 "BUILTIN_ENABLED | STATIC_BUILTIN",
60 (builtin->flags & BUILTIN_FLAG_SPECIAL) ? " | SPECIAL_BUILTIN" : "",
61 (builtin->flags & BUILTIN_FLAG_ASSIGNMENT) ? " | ASSIGNMENT_BUILTIN" : "",
62 + (builtin->flags & BUILTIN_FLAG_REQUIRES) ? " | REQUIRES_BUILTIN" : "",
63 builtin->docname ? builtin->docname : builtin->name);
66 @@ -1401,6 +1417,13 @@
69 return (_find_in_table (name, assignment_builtins));
73 +is_requires_builtin (name)
76 + return (_find_in_table (name, requires_builtins));
79 #if !defined (HAVE_RENAME)
80 diff -r -u bash-2.03.orig/builtins.h bash-2.03.new/builtins.h
81 --- bash-2.03.orig/builtins.h Fri Jul 18 16:46:36 1997
82 +++ bash-2.03.new/builtins.h Thu Jul 15 16:59:03 1999
84 #define STATIC_BUILTIN 0x4 /* This builtin is not dynamically loaded. */
85 #define SPECIAL_BUILTIN 0x8 /* This is a Posix `special' builtin. */
86 #define ASSIGNMENT_BUILTIN 0x10 /* This builtin takes assignment statements. */
87 +#define REQUIRES_BUILTIN 0x20 /* This builtin requires other files. */
89 /* The thing that we build the array of builtins out of. */
91 diff -r -u bash-2.03.orig/doc/bash.1 bash-2.03.new/doc/bash.1
92 --- bash-2.03.orig/doc/bash.1 Wed Jan 20 16:48:04 1999
93 +++ bash-2.03.new/doc/bash.1 Fri Jul 16 11:20:00 1999
99 +Produce the list of files that are required for the
100 +shell script to run. This implies '-n' and is subject
101 +to the same limitations as compile time error checking checking;
102 +Backticks, [] tests, and evals are not parsed so some
103 +dependencies may be missed.
105 Equivalent to \fB\-v\fP.
107 diff -r -u bash-2.03.orig/doc/bashref.texi bash-2.03.new/doc/bashref.texi
108 --- bash-2.03.orig/doc/bashref.texi Wed Jan 20 16:47:01 1999
109 +++ bash-2.03.new/doc/bashref.texi Fri Jul 16 11:21:30 1999
110 @@ -3178,6 +3178,13 @@
112 Make the shell a restricted shell (@pxref{The Restricted Shell}).
114 +@item --rpm-requires
115 +Produce the list of files that are required for the
116 +shell script to run. This implies '-n' and is subject
117 +to the same limitations as compile time error checking checking;
118 +Backticks, [] tests, and evals are not parsed so some
119 +dependencies may be missed.
122 Equivalent to @samp{-v}.
124 diff -r -u bash-2.03.orig/make_cmd.c bash-2.03.new/make_cmd.c
125 --- bash-2.03.orig/make_cmd.c Tue Jan 12 12:45:36 1999
126 +++ bash-2.03.new/make_cmd.c Fri Jul 16 11:48:18 1999
131 +#include "builtins.h"
133 #if defined (JOB_CONTROL)
137 extern int line_number, current_command_line_count;
138 extern int disallow_filename_globbing;
139 +extern int rpm_requires;
142 make_bare_word (string)
144 return (make_command (cm_function_def, (SIMPLE_COM *)temp));
148 +output_requirement (file)
151 + if (file[0] != '/') {
152 + /* if we are not given a full path name we require the basename
153 + otherwise we require the full path. This does not work in the
154 + Win/Dos world but I don't know what to do there.*/
156 + basename = strrchr(file, '/');
162 + printf ("bash(%s)\n", file);
165 /* Reverse the word list and redirection list in the simple command
166 has just been parsed. It seems simpler to do this here the one
167 time then by any other method that I can think of. */
169 command->value.Simple->redirects =
170 REVERSE_LIST (command->value.Simple->redirects, REDIRECT *);
179 + cmd0 = command->value.Simple->words->word->word;
180 + b = builtin_address_internal (cmd0, 0);
182 + if (b->flags & REQUIRES_BUILTIN){
183 + cmd1 = command->value.Simple->words->next->word->word;
184 + output_requirement(cmd1);
187 + if (!assignment(cmd0))
188 + output_requirement(cmd0);
194 diff -r -u bash-2.03.orig/shell.c bash-2.03.new/shell.c
195 --- bash-2.03.orig/shell.c Thu Feb 18 11:42:27 1999
196 +++ bash-2.03.new/shell.c Fri Jul 16 11:30:57 1999
198 /* The name of the .(shell)rc file. */
199 static char *bashrc_file = "~/.bashrc";
201 +/* Non-zero if we are finding the scripts requirements. */
204 /* Non-zero means to act more like the Bourne shell on startup. */
205 static int act_like_sh;
208 { "norc", Int, &no_rc, (char **)0x0 },
209 { "posix", Int, &posixly_correct, (char **)0x0 },
210 { "rcfile", Charp, (int *)0x0, &bashrc_file },
211 + { "rpm-requires", Int, &rpm_requires, (char **)0x0 },
212 #if defined (RESTRICTED_SHELL)
213 { "restricted", Int, &restricted, (char **)0x0 },
217 if (dump_translatable_strings)
218 read_but_dont_execute = 1;
222 + read_but_dont_execute = 1;
223 + initialize_shell_builtins ();
226 if (running_setuid && privileged_mode == 0)
227 disable_priv_mode ();