]> git.pld-linux.org Git - packages/bash.git/blobdiff - bash-requires.patch
Up to 5.2.26
[packages/bash.git] / bash-requires.patch
index 1bf4415fdb00c3b8c526644c6d5f1196bcf63467..674e5b9483b861fbbe654f30dbf3b06dc23e4deb 100644 (file)
@@ -1,19 +1,42 @@
---- bash-2.05b/builtins/mkbuiltins.c.requires  Thu Aug  5 12:42:54 1999
-+++ bash-2.05b/builtins/mkbuiltins.c   Sun Mar 19 14:14:17 2000
-@@ -72,6 +72,7 @@
+diff --git a/builtins.h b/builtins.h
+--- a/builtins.h
++++ b/builtins.h
+@@ -46,6 +46,7 @@
+ #define POSIX_BUILTIN 0x20    /* This builtins is special in the Posix command search order. */
+ #define LOCALVAR_BUILTIN   0x40       /* This builtin creates local variables */
+ #define ARRAYREF_BUILTIN 0x80 /* This builtin takes array references as arguments */
++#define REQUIRES_BUILTIN 0x100  /* This builtin requires other files. */
+ #define BASE_INDENT   4
+diff --git a/builtins/mkbuiltins.c b/builtins/mkbuiltins.c
+--- a/builtins/mkbuiltins.c
++++ b/builtins/mkbuiltins.c
+@@ -69,11 +69,16 @@ extern char *strcpy ();
+ #define whitespace(c) (((c) == ' ') || ((c) == '\t'))
+ /* Flag values that builtins can have. */
++/*  These flags are for the C code generator,
++    the C which is produced (./builtin.c)
++    includes the flags definitions found
++    in ../builtins.h */
  #define BUILTIN_FLAG_SPECIAL  0x01
  #define BUILTIN_FLAG_ASSIGNMENT 0x02
- #define BUILTIN_FLAG_POSIX_BUILTIN 0x04
-+#define BUILTIN_FLAG_REQUIRES 0x08
+ #define BUILTIN_FLAG_LOCALVAR 0x04
+ #define BUILTIN_FLAG_POSIX_BUILTIN    0x08
+ #define BUILTIN_FLAG_ARRAYREF_ARG     0x10
++#define BUILTIN_FLAG_REQUIRES  0x20
  
  #define BASE_INDENT   4
  
-@@ -164,10 +164,18 @@
+@@ -189,13 +194,21 @@ char *arrayvar_builtins[] =
+   "typeset", "unset", "wait",         /*]*/
    (char *)NULL
  };
+-      
++
 +/* The builtin commands that cause requirements on other files. */
-+char *requires_builtins[] =
++static char *requires_builtins[] =
 +{
 +  ".", "command", "exec", "source", "inlib",
 +  (char *)NULL
  /* Forward declarations. */
  static int is_special_builtin ();
  static int is_assignment_builtin ();
+ static int is_localvar_builtin ();
  static int is_posix_builtin ();
+ static int is_arrayvar_builtin ();
 +static int is_requires_builtin ();
  
  #if !defined (HAVE_RENAME)
  static int rename ();
-@@ -821,6 +821,8 @@
-     new->flags |= BUILTIN_FLAG_ASSIGNMENT;
-   if (is_posix_builtin (name))
+@@ -856,6 +869,8 @@ builtin_handler (self, defs, arg)
      new->flags |= BUILTIN_FLAG_POSIX_BUILTIN;
+   if (is_arrayvar_builtin (name))
+     new->flags |= BUILTIN_FLAG_ARRAYREF_ARG;
 +  if (is_requires_builtin (name))
 +    new->flags |= BUILTIN_FLAG_REQUIRES;
  
    array_add ((char *)new, defs->builtins);
    building_builtin = 1;
-@@ -1240,11 +1240,12 @@
+@@ -1275,13 +1290,14 @@ write_builtins (defs, structfile, externfile)
                  else
                    fprintf (structfile, "(sh_builtin_func_t *)0x0, ");
  
--                fprintf (structfile, "%s%s%s%s, %s_doc,\n",
-+                fprintf (structfile, "%s%s%s%s%s, %s_doc,\n",
+-                fprintf (structfile, "%s%s%s%s%s%s, %s_doc,\n",
++                fprintf (structfile, "%s%s%s%s%s%s%s, %s_doc,\n",
                    "BUILTIN_ENABLED | STATIC_BUILTIN",
                    (builtin->flags & BUILTIN_FLAG_SPECIAL) ? " | SPECIAL_BUILTIN" : "",
                    (builtin->flags & BUILTIN_FLAG_ASSIGNMENT) ? " | ASSIGNMENT_BUILTIN" : "",
+                   (builtin->flags & BUILTIN_FLAG_LOCALVAR) ? " | LOCALVAR_BUILTIN" : "",
                    (builtin->flags & BUILTIN_FLAG_POSIX_BUILTIN) ? " | POSIX_BUILTIN" : "",
+                   (builtin->flags & BUILTIN_FLAG_ARRAYREF_ARG) ? " | ARRAYREF_BUILTIN" : "",
 +                  (builtin->flags & BUILTIN_FLAG_REQUIRES) ? " | REQUIRES_BUILTIN" : "",
                    document_name (builtin));
  
-                 fprintf
-@@ -1401,6 +1417,13 @@
-      char *name;
- {
-   return (_find_in_table (name, assignment_builtins));
-+}
-+
+                 /* Don't translate short document summaries that are identical
+@@ -1678,6 +1694,13 @@ is_arrayvar_builtin (name)
+   return (_find_in_table (name, arrayvar_builtins));
+ }
 +static int
 +is_requires_builtin (name)
 +     char *name;
 +{
 +  return (_find_in_table (name, requires_builtins));
- }
++}
++
  #if !defined (HAVE_RENAME)
---- bash-2.04-beta5/doc/bash.1.requires        Tue Jan 11 19:36:49 2000
-+++ bash-2.04-beta5/doc/bash.1 Sun Mar 19 14:14:17 2000
-@@ -196,6 +196,12 @@
+ static int
+ rename (from, to)
+diff --git a/doc/bash.1 b/doc/bash.1
+--- a/doc/bash.1
++++ b/doc/bash.1
+@@ -239,6 +239,14 @@ The shell becomes restricted (see
  .B "RESTRICTED SHELL"
  below).
  .TP
 +.B \-\-rpm-requires
-+Produce the list of files that are required for the 
++Produce the list of files that are required for the
 +shell script to run.  This implies '-n' and is subject
 +to the same limitations as compile time error checking checking;
-+Backticks, [] tests,  and evals are not parsed so some 
-+dependencies may be missed.
++Command substitutions, Conditional expressions and
++.BR eval
++builtin are not parsed so some dependencies may be missed.
++.TP
  .B \-\-verbose
- Equivalent to  \fB\-v\fP.
+ Equivalent to \fB\-v\fP.
  .TP
---- bash-2.04-beta5/doc/bashref.texi.requires  Wed Jan 12 16:18:50 2000
-+++ bash-2.04-beta5/doc/bashref.texi   Sun Mar 19 14:14:17 2000
-@@ -4333,6 +4333,13 @@
+diff --git a/doc/bashref.texi b/doc/bashref.texi
+--- a/doc/bashref.texi
++++ b/doc/bashref.texi
+@@ -6927,6 +6927,13 @@ standard.  @xref{Bash POSIX Mode}, for a description of the Bash
  @item --restricted
  Make the shell a restricted shell (@pxref{The Restricted Shell}).
  
 +@item --rpm-requires
-+Produce the list of files that are required for the 
++Produce the list of files that are required for the
 +shell script to run.  This implies '-n' and is subject
 +to the same limitations as compile time error checking checking;
-+Backticks, [] tests,  and evals are not parsed so some 
-+dependencies may be missed.
++Command substitutions, Conditional expressions and @command{eval}
++are not parsed so some dependencies may be missed.
 +
  @item --verbose
- Equivalent to @samp{-v}.  Print shell input lines as they're read.
+ Equivalent to @option{-v}.  Print shell input lines as they're read.
  
---- bash-2.04-beta5/builtins.h.requires        Thu Aug  5 11:18:12 1999
-+++ bash-2.04-beta5/builtins.h Sun Mar 19 14:14:17 2000
-@@ -41,6 +41,7 @@
- #define SPECIAL_BUILTIN 0x08  /* This is a Posix `special' builtin. */
- #define ASSIGNMENT_BUILTIN 0x10       /* This builtin takes assignment statements. */
- #define POSIX_BUILTIN 0x20    /* This builtins is special in the Posix command search order. */
-+#define REQUIRES_BUILTIN      0x40    /* This builtin requires other files. */
- #define BASE_INDENT   4
+diff --git a/eval.c b/eval.c
+--- a/eval.c
++++ b/eval.c
+@@ -138,7 +138,8 @@ reader_loop ()
  
---- bash-2.04-beta5/make_cmd.c.requires        Thu Aug  5 11:21:23 1999
-+++ bash-2.04-beta5/make_cmd.c Sun Mar 19 14:17:34 2000
-@@ -41,6 +41,9 @@
- #include "subst.h"
- #include "input.h"
- #include "externs.h"
-+#include "builtins.h"
+       if (read_command () == 0)
+       {
+-        if (interactive_shell == 0 && read_but_dont_execute)
 +
-+#include "builtins/common.h"
++        if (interactive_shell == 0 && (read_but_dont_execute && !rpm_requires))
+           {
+             set_exit_status (last_command_exit_value);
+             dispose_command (global_command);
+diff --git a/execute_cmd.c b/execute_cmd.c
+--- a/execute_cmd.c
++++ b/execute_cmd.c
+@@ -561,6 +561,8 @@ async_redirect_stdin ()
  
- #if defined (JOB_CONTROL)
- #include "jobs.h"
-@@ -49,6 +52,9 @@
+ #define DESCRIBE_PID(pid) do { if (interactive) describe_pid (pid); } while (0)
  
- extern int line_number, current_command_line_count;
- extern int last_command_exit_value;
 +extern int rpm_requires;
-+char *alphabet_set = "abcdefghijklmnopqrstuvwxyz"
-+                   "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
++
+ /* Execute the command passed in COMMAND, perhaps doing it asynchronously.
+    COMMAND is exactly what read_command () places into GLOBAL_COMMAND.
+    ASYNCHRONOUS, if non-zero, says to do this command in the background.
+@@ -592,7 +594,13 @@ execute_command_internal (command, asynchronous, pipe_in, pipe_out,
+   if (breaking || continuing)
+     return (last_command_exit_value);
+-  if (read_but_dont_execute)
++  if (command == 0 || (read_but_dont_execute && !rpm_requires))
++    return (EXECUTION_SUCCESS);
++  if (rpm_requires && command->type == cm_function_def)
++    return last_command_exit_value =
++      execute_intern_function (command->value.Function_def->name,
++                              command->value.Function_def);
++ if (read_but_dont_execute)
+     return (last_command_exit_value);
+   if (command == 0)
+     return (EXECUTION_SUCCESS);
+@@ -2883,7 +2891,7 @@ execute_for_command (for_command)
+   save_line_number = line_number;
+   if (check_identifier (for_command->name, 1) == 0)
+     {
+-      if (posixly_correct && interactive_shell == 0)
++      if (posixly_correct && interactive_shell == 0 && rpm_requires == 0)
+       {
+         last_command_exit_value = EX_BADUSAGE;
+         jump_to_top_level (ERREXIT);
+diff --git a/execute_cmd.h b/execute_cmd.h
+--- a/execute_cmd.h
++++ b/execute_cmd.h
+@@ -22,6 +22,9 @@
+ #define _EXECUTE_CMD_H_
+ #include "stdc.h"
++#include "variables.h"
++#include "command.h"
++
  
- static COMMAND *make_for_or_select __P((enum command_type, WORD_DESC *, WORD_LIST *, COMMAND *));
- #if defined (ARITH_FOR_COMMAND)
-@@ -696,6 +702,36 @@
-   return (make_command (cm_subshell, (SIMPLE_COM *)temp));
+ #if defined (ARRAY_VARS)
+ struct func_array_state
+diff --git a/make_cmd.c b/make_cmd.c
+--- a/make_cmd.c
++++ b/make_cmd.c
+@@ -35,6 +35,8 @@
+ #include "bashintl.h"
+ #include "shell.h"
++#include "builtins.h"
++#include "builtins/common.h"
+ #include "execute_cmd.h"
+ #include "parser.h"
+ #include "flags.h"
+@@ -839,6 +841,30 @@ make_coproc_command (name, command)
+   return (make_command (cm_coproc, (SIMPLE_COM *)temp));
  }
  
-+void
-+output_requirement (file)
-+char *file;
++static void
++output_requirement (deptype, filename)
++const char *deptype;
++char *filename;
 +{
-+  if ( (file[0] != '/') || strchr(file, '$')) {
-+    /* if we are not given a full path name we require the basename
-+       otherwise we require the full path.  This does not work in the
-+       Win/Dos world but I don't know what to do there.*/
-+    char *basename;
-+    basename = strrchr(file, '/');
-+    if (basename) {    
-+      basename++;
-+      file=basename;
-+    }
-+  }  
++  static char *alphabet_set = "abcdefghijklmnopqrstuvwxyz"
++                    "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
++
++  if (strchr(filename, '$') || (filename[0] != '/' && strchr(filename, '/')))
++    return;
 +
-+    /* 
-+       if the executable is called via variable substitution we can
-+       not dermine what it is at compile time.  
++  /*
++      if the executable is called via variable substitution we can
++      not dermine what it is at compile time.
 +
-+       if the executable consists only of characters not in the
-+       alphabet we do not consider it a dependency just an artifact of
-+       shell parsing (ex "exec < ${infile}").
-+    */
++      if the executable consists only of characters not in the
++      alphabet we do not consider it a dependency just an artifact
++      of shell parsing (ex "exec < ${infile}").
++  */
 +
-+  if ( !strchr(file, '$') && strpbrk(file, alphabet_set) ) {
-+    printf ("executable(%s)\n", file);
-+  }
++  if (strpbrk(filename, alphabet_set))
++    printf ("%s(%s)\n", deptype, filename);
 +}
 +
  /* Reverse the word list and redirection list in the simple command
     has just been parsed.  It seems simpler to do this here the one
     time then by any other method that I can think of. */
-@@ -712,6 +748,35 @@
-       command->value.Simple->redirects =
+@@ -856,6 +882,28 @@ clean_simple_command (command)
        REVERSE_LIST (command->value.Simple->redirects, REDIRECT *);
      }
-+
 +  if (rpm_requires && command->value.Simple->words)
 +    {
 +      char *cmd0;
 +      cmd0 = command->value.Simple->words->word->word;
 +      b = builtin_address_internal (cmd0, 0);
 +      cmd1 = 0;
-+      if (command->value.Simple->words->next) {
-+      cmd1 = command->value.Simple->words->next->word->word;
-+      }
++      if (command->value.Simple->words->next)
++        cmd1 = command->value.Simple->words->next->word->word;
++
 +      if (b) {
-+      if ( (b->flags & REQUIRES_BUILTIN) && cmd1){
-+        output_requirement(cmd1);
-+      }
++        if ( (b->flags & REQUIRES_BUILTIN) && cmd1)
++          output_requirement ("executable", cmd1);
 +      } else {
-+      if (!assignment(cmd0, 0)) {
-+        output_requirement(cmd0);
-+      } else {
-+
-+        /* This will not work, the subshell that this runs in does
-+             not get the "requires" commandline argument. */
-+
-+        execute_command(command);
-+      }
++        if (!assignment(cmd0, 0))
++          output_requirement (find_function(cmd0) ? "function" : "executable", cmd0);
 +      }
 +    } /*rpm_requires*/
++
++
+   parser_state &= ~PST_REDIRLIST;
    return (command);
  }
---- bash-2.04-beta5/shell.c.requires   Fri Nov 19 19:58:15 1999
-+++ bash-2.04-beta5/shell.c    Sun Mar 19 14:14:17 2000
-@@ -163,6 +163,9 @@
+diff --git a/shell.c b/shell.c
+--- a/shell.c
++++ b/shell.c
+@@ -196,6 +196,9 @@ int have_devfd = 0;
  /* The name of the .(shell)rc file. */
- static char *bashrc_file = "~/.bashrc";
+ static char *bashrc_file = DEFAULT_BASHRC;
  
 +/* Non-zero if we are finding the scripts requirements. */
 +int rpm_requires;
  /* Non-zero means to act more like the Bourne shell on startup. */
  static int act_like_sh;
  
-@@ -208,6 +211,7 @@
-   { "norc", Int, &no_rc, (char **)0x0 },
-   { "posix", Int, &posixly_correct, (char **)0x0 },
+@@ -266,6 +269,7 @@ static const struct {
+   { "protected", Int, &protected_mode, (char **)0x0 },
+ #endif
    { "rcfile", Charp, (int *)0x0, &bashrc_file },
 +  { "rpm-requires", Int, &rpm_requires, (char **)0x0 },
  #if defined (RESTRICTED_SHELL)
    { "restricted", Int, &restricted, (char **)0x0 },
  #endif
-@@ -393,6 +397,12 @@
-   if (dump_translatable_strings)
+@@ -510,6 +514,12 @@ main (argc, argv, env)
      read_but_dont_execute = 1;
-+
+ #endif
 +  if (rpm_requires)
 +    {
 +      read_but_dont_execute = 1;
 +      initialize_shell_builtins ();
 +    }
++
    if (running_setuid && privileged_mode == 0)
      disable_priv_mode ();
+diff --git a/shell.h b/shell.h
+--- a/shell.h
++++ b/shell.h
+@@ -100,6 +100,7 @@ extern int interactive, interactive_shell;
+ extern int startup_state;
+ extern int reading_shell_script;
+ extern int shell_initialized;
++extern int rpm_requires;
+ extern int bash_argv_initialized;
+ extern int subshell_environment;
+ extern int current_command_number;
This page took 0.065073 seconds and 4 git commands to generate.