]> git.pld-linux.org Git - packages/bash.git/blob - bash-requires.patch
- patches from rawhode.
[packages/bash.git] / bash-requires.patch
1
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.
4
5 Ken
6
7
8
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
12 @@ -51,8 +51,13 @@
13  #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
14  
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 
19 +    in ../builtins.h */
20  #define BUILTIN_FLAG_SPECIAL   0x01
21  #define BUILTIN_FLAG_ASSIGNMENT 0x02
22 +#define BUILTIN_FLAG_REQUIRES  0x04
23  
24  /* If this stream descriptor is non-zero, then write
25     texinfo documentation to it. */
26 @@ -126,9 +131,17 @@
27    (char *)NULL
28  };
29  
30 +/* The builtin commands that cause requirements on other files. */
31 +char *requires_builtins[] =
32 +{
33 +  ".", "command", "exec", "source", "inlib",
34 +  (char *)NULL
35 +};
36 +
37  /* Forward declarations. */
38  static int is_special_builtin ();
39  static int is_assignment_builtin ();
40 +static int is_requires_builtin ();
41  
42  #if !defined (HAVE_RENAME)
43  static int rename ();
44 @@ -759,6 +772,8 @@
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;
50  
51    array_add ((char *)new, defs->builtins);
52    building_builtin = 1;
53 @@ -1164,10 +1179,11 @@
54                   else
55                     fprintf (structfile, "(Function *)0x0, ");
56  
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);
64  
65                   fprintf
66 @@ -1401,6 +1417,13 @@
67       char *name;
68  {
69    return (_find_in_table (name, assignment_builtins));
70 +}
71 +
72 +static int
73 +is_requires_builtin (name)
74 +     char *name;
75 +{
76 +  return (_find_in_table (name, requires_builtins));
77  }
78  
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
83 @@ -40,6 +40,7 @@
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. */
88  
89  /* The thing that we build the array of builtins out of. */
90  struct builtin {
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
94 @@ -195,6 +195,12 @@
95  .B "RESTRICTED SHELL"
96  below).
97  .TP
98 +.B \-\-rpm-requires
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.
104  .B \-\-verbose
105  Equivalent to  \fB\-v\fP.
106  .TP
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 @@
111  @item --restricted
112  Make the shell a restricted shell (@pxref{The Restricted Shell}).
113  
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.
120 +
121  @item --verbose
122  Equivalent to @samp{-v}.
123  
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
127 @@ -41,6 +41,7 @@
128  #include "subst.h"
129  #include "input.h"
130  #include "externs.h"
131 +#include "builtins.h"
132  
133  #if defined (JOB_CONTROL)
134  #include "jobs.h"
135 @@ -48,6 +49,7 @@
136  
137  extern int line_number, current_command_line_count;
138  extern int disallow_filename_globbing;
139 +extern int rpm_requires;
140  
141  WORD_DESC *
142  make_bare_word (string)
143 @@ -588,6 +590,24 @@
144    return (make_command (cm_function_def, (SIMPLE_COM *)temp));
145  }
146  
147 +void
148 +output_requirement (file)
149 +char *file;
150 +{
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.*/
155 +    char *basename;
156 +    basename = strrchr(file, '/');
157 +    if (basename) {    
158 +      basename++;
159 +      file=basename;
160 +    }
161 +  }  
162 +  printf ("bash(%s)\n", file);
163 +}
164 +
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. */
168 @@ -604,6 +624,25 @@
169        command->value.Simple->redirects =
170         REVERSE_LIST (command->value.Simple->redirects, REDIRECT *);
171      }
172 +
173 +  if (rpm_requires)
174 +    {
175 +      char *cmd0;
176 +      char *cmd1;
177 +      struct builtin *b;
178 +
179 +      cmd0 = command->value.Simple->words->word->word;
180 +      b = builtin_address_internal (cmd0, 0);
181 +      if (b) {
182 +       if (b->flags & REQUIRES_BUILTIN){
183 +         cmd1 = command->value.Simple->words->next->word->word;
184 +         output_requirement(cmd1);
185 +       }
186 +      } else {
187 +       if (!assignment(cmd0))
188 +         output_requirement(cmd0);
189 +      }
190 +    } /*rpm_requires*/
191  
192    return (command);
193  }
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
197 @@ -170,6 +170,9 @@
198  /* The name of the .(shell)rc file. */
199  static char *bashrc_file = "~/.bashrc";
200  
201 +/* Non-zero if we are finding the scripts requirements. */
202 +int rpm_requires;
203 +
204  /* Non-zero means to act more like the Bourne shell on startup. */
205  static int act_like_sh;
206  
207 @@ -215,6 +218,7 @@
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 },
214  #endif
215 @@ -398,6 +402,12 @@
216  
217    if (dump_translatable_strings)
218      read_but_dont_execute = 1;
219 +
220 +  if (rpm_requires)
221 +    {
222 +      read_but_dont_execute = 1;
223 +      initialize_shell_builtins ();
224 +    }
225  
226    if (running_setuid && privileged_mode == 0)
227      disable_priv_mode ();
228
229
This page took 0.081989 seconds and 4 git commands to generate.