svashisht / rpms / bash

Forked from rpms/bash 6 years ago
Clone
aaec1fb
diff --git a/builtins/common.h b/builtins/common.h
aaec1fb
--- a/builtins/common.h
aaec1fb
+++ b/builtins/common.h
aaec1fb
@@ -257,6 +257,10 @@ extern int print_shift_error;
aaec1fb
 extern int expand_once_flag;
aaec1fb
 #endif
aaec1fb
 
aaec1fb
+#if defined (EXTENDED_GLOB)
aaec1fb
+extern int extglob_flag;
aaec1fb
+#endif
aaec1fb
+
aaec1fb
 extern int expaliases_flag;
aaec1fb
 
aaec1fb
 /* variables from source.def */
aaec1fb
diff --git a/builtins/shopt.def b/builtins/shopt.def
aaec1fb
--- a/builtins/shopt.def
aaec1fb
+++ b/builtins/shopt.def
aaec1fb
@@ -149,6 +149,11 @@ static int shopt_set_complete_direxpand PARAMS((char *, int));
aaec1fb
 static int set_assoc_expand PARAMS((char *, int));
aaec1fb
 #endif
aaec1fb
 
aaec1fb
+#if defined (EXTENDED_GLOB)
aaec1fb
+int extglob_flag = EXTGLOB_DEFAULT;
aaec1fb
+static int shopt_set_extglob PARAMS((char *, int));
aaec1fb
+#endif
aaec1fb
+
aaec1fb
 int expaliases_flag = 0;
aaec1fb
 static int shopt_set_expaliases PARAMS((char *, int));
aaec1fb
 
aaec1fb
@@ -206,7 +211,7 @@ static struct {
aaec1fb
   { "extdebug", &debugging_mode, shopt_set_debug_mode },
aaec1fb
 #endif
aaec1fb
 #if defined (EXTENDED_GLOB)
aaec1fb
-  { "extglob", &extended_glob, (shopt_set_func_t *)NULL },
aaec1fb
+  { "extglob", &extglob_flag, shopt_set_extglob },
aaec1fb
 #endif
aaec1fb
   { "extquote", &extended_quote, (shopt_set_func_t *)NULL },
aaec1fb
   { "failglob", &fail_glob_expansion, (shopt_set_func_t *)NULL },
aaec1fb
@@ -377,7 +382,7 @@ reset_shopt_options ()
aaec1fb
 #endif
aaec1fb
 
aaec1fb
 #if defined (EXTENDED_GLOB)
aaec1fb
-  extended_glob = EXTGLOB_DEFAULT;
aaec1fb
+  extended_glob = extglob_flag = EXTGLOB_DEFAULT;
aaec1fb
 #endif
aaec1fb
 
aaec1fb
 #if defined (ARRAY_VARS)
aaec1fb
@@ -643,6 +648,17 @@ shopt_set_expaliases (option_name, mode)
aaec1fb
   return 0;
aaec1fb
 }
aaec1fb
 
aaec1fb
+#if defined (EXTENDED_GLOB)
aaec1fb
+static int
aaec1fb
+shopt_set_extglob (option_name, mode)
aaec1fb
+     char *option_name;
aaec1fb
+     int mode;
aaec1fb
+{
aaec1fb
+  extended_glob = extglob_flag;
aaec1fb
+  return 0;
aaec1fb
+}
aaec1fb
+#endif
aaec1fb
+
aaec1fb
 #if defined (READLINE)
aaec1fb
 static int
aaec1fb
 shopt_enable_hostname_completion (option_name, mode)
aaec1fb
diff --git a/execute_cmd.c b/execute_cmd.c
aaec1fb
--- a/execute_cmd.c
aaec1fb
+++ b/execute_cmd.c
aaec1fb
@@ -3990,13 +3990,11 @@ execute_cond_node (cond)
aaec1fb
       else
aaec1fb
 #endif /* COND_REGEXP */
aaec1fb
 	{
aaec1fb
-	  int oe;
aaec1fb
-	  oe = extended_glob;
aaec1fb
 	  extended_glob = 1;
aaec1fb
 	  result = binary_test (cond->op->word, arg1, arg2, TEST_PATMATCH|TEST_ARITHEXP|TEST_LOCALE)
aaec1fb
 				  ? EXECUTION_SUCCESS
aaec1fb
 				  : EXECUTION_FAILURE;
aaec1fb
-	  extended_glob = oe;
aaec1fb
+	  extended_glob = extglob_flag;
aaec1fb
 	}
aaec1fb
       if (arg1 != nullstr)
aaec1fb
 	free (arg1);
aaec1fb
diff --git a/parse.y b/parse.y
aaec1fb
--- a/parse.y
aaec1fb
+++ b/parse.y
aaec1fb
@@ -125,7 +125,7 @@ do { \
aaec1fb
 } while (0)
aaec1fb
 
aaec1fb
 #if defined (EXTENDED_GLOB)
aaec1fb
-extern int extended_glob;
aaec1fb
+extern int extended_glob, extglob_flag;
aaec1fb
 #endif
aaec1fb
 
aaec1fb
 #if defined (TRANSLATABLE_STRINGS)
aaec1fb
@@ -3304,7 +3304,7 @@ reset_parser ()
aaec1fb
 #if defined (EXTENDED_GLOB)
aaec1fb
   /* Reset to global value of extended glob */
aaec1fb
   if (parser_state & (PST_EXTPAT|PST_CMDSUBST))
aaec1fb
-    extended_glob = global_extglob;
aaec1fb
+    extended_glob = extglob_flag;
aaec1fb
 #endif
aaec1fb
   if (parser_state & (PST_CMDSUBST|PST_STRING))
aaec1fb
     expand_aliases = expaliases_flag;
aaec1fb
@@ -4124,10 +4124,10 @@ parse_comsub (qc, open, close, lenp, flags)
aaec1fb
     expand_aliases = posixly_correct != 0;
aaec1fb
 #if defined (EXTENDED_GLOB)
aaec1fb
   /* If (parser_state & PST_EXTPAT), we're parsing an extended pattern for a
aaec1fb
-     conditional command and have already set global_extglob appropriately. */
aaec1fb
+     conditional command and have already set extended_glob appropriately. */
aaec1fb
   if (shell_compatibility_level <= 51 && was_extpat == 0)
aaec1fb
     {
aaec1fb
-      local_extglob = global_extglob = extended_glob;
aaec1fb
+      local_extglob = extended_glob;
aaec1fb
       extended_glob = 1;
aaec1fb
     }
aaec1fb
 #endif
aaec1fb
@@ -4235,7 +4235,7 @@ xparse_dolparen (base, string, indp, flags)
aaec1fb
 {
aaec1fb
   sh_parser_state_t ps;
aaec1fb
   sh_input_line_state_t ls;
aaec1fb
-  int orig_ind, nc, sflags, start_lineno;
aaec1fb
+  int orig_ind, nc, sflags, start_lineno, local_extglob;
aaec1fb
   char *ret, *ep, *ostring;
aaec1fb
 
aaec1fb
 /*debug_parser(1);*/
aaec1fb
@@ -4278,7 +4278,7 @@ xparse_dolparen (base, string, indp, flags)
aaec1fb
      old value will be restored by restore_parser_state(). */
aaec1fb
   expand_aliases = 0;
aaec1fb
 #if defined (EXTENDED_GLOB)
aaec1fb
-  global_extglob = extended_glob;		/* for reset_parser() */
aaec1fb
+  local_extglob = extended_glob;
aaec1fb
 #endif
aaec1fb
 
aaec1fb
   token_to_read = DOLPAREN;			/* let's trick the parser */
aaec1fb
@@ -4296,6 +4296,9 @@ xparse_dolparen (base, string, indp, flags)
aaec1fb
   restore_input_line_state (&ls);
aaec1fb
   restore_parser_state (&ps);
aaec1fb
 
aaec1fb
+#if defined (EXTENDED_GLOB)
aaec1fb
+  extended_glob = local_extglob;
aaec1fb
+#endif
aaec1fb
   token_to_read = 0;
aaec1fb
 
aaec1fb
   /* If parse_string returns < 0, we need to jump to top level with the
aaec1fb
@@ -4731,12 +4734,16 @@ cond_term ()
aaec1fb
 	}
aaec1fb
 
aaec1fb
       /* rhs */
aaec1fb
+#if defined (EXTENDED_GLOB)
aaec1fb
       local_extglob = extended_glob;
aaec1fb
       if (parser_state & PST_EXTPAT)
aaec1fb
 	extended_glob = 1;
aaec1fb
+#endif
aaec1fb
       tok = read_token (READ);
aaec1fb
+#if defined (EXTENDED_GLOB)
aaec1fb
       if (parser_state & PST_EXTPAT)
aaec1fb
 	extended_glob = local_extglob;
aaec1fb
+#endif
aaec1fb
       parser_state &= ~(PST_REGEXP|PST_EXTPAT);
aaec1fb
 
aaec1fb
       if (tok == WORD)
aaec1fb
@@ -4783,7 +4790,6 @@ parse_cond_command ()
aaec1fb
 {
aaec1fb
   COND_COM *cexp;
aaec1fb
 
aaec1fb
-  global_extglob = extended_glob;
aaec1fb
   cexp = cond_expr ();
aaec1fb
   return (make_cond_command (cexp));
aaec1fb
 }
aaec1fb
diff --git a/patchlevel.h b/patchlevel.h
aaec1fb
--- a/patchlevel.h
aaec1fb
+++ b/patchlevel.h
aaec1fb
@@ -25,6 +25,6 @@
aaec1fb
    regexp `^#define[ 	]*PATCHLEVEL', since that's what support/mkversion.sh
aaec1fb
    looks for to find the patch level (for the sccs version string). */
aaec1fb
 
aaec1fb
-#define PATCHLEVEL 11
aaec1fb
+#define PATCHLEVEL 12
aaec1fb
 
aaec1fb
 #endif /* _PATCHLEVEL_H_ */
aaec1fb
diff --git a/y.tab.c b/y.tab.c
aaec1fb
--- a/y.tab.c
aaec1fb
+++ b/y.tab.c
aaec1fb
@@ -175,7 +175,7 @@ do { \
aaec1fb
 } while (0)
aaec1fb
 
aaec1fb
 #if defined (EXTENDED_GLOB)
aaec1fb
-extern int extended_glob;
aaec1fb
+extern int extended_glob, extglob_flag;
aaec1fb
 #endif
aaec1fb
 
aaec1fb
 #if defined (TRANSLATABLE_STRINGS)
aaec1fb
@@ -5615,7 +5615,7 @@ reset_parser ()
aaec1fb
 #if defined (EXTENDED_GLOB)
aaec1fb
   /* Reset to global value of extended glob */
aaec1fb
   if (parser_state & (PST_EXTPAT|PST_CMDSUBST))
aaec1fb
-    extended_glob = global_extglob;
aaec1fb
+    extended_glob = extglob_flag;
aaec1fb
 #endif
aaec1fb
   if (parser_state & (PST_CMDSUBST|PST_STRING))
aaec1fb
     expand_aliases = expaliases_flag;
aaec1fb
@@ -6435,10 +6435,10 @@ parse_comsub (qc, open, close, lenp, flags)
aaec1fb
     expand_aliases = posixly_correct != 0;
aaec1fb
 #if defined (EXTENDED_GLOB)
aaec1fb
   /* If (parser_state & PST_EXTPAT), we're parsing an extended pattern for a
aaec1fb
-     conditional command and have already set global_extglob appropriately. */
aaec1fb
+     conditional command and have already set extended_glob appropriately. */
aaec1fb
   if (shell_compatibility_level <= 51 && was_extpat == 0)
aaec1fb
     {
aaec1fb
-      local_extglob = global_extglob = extended_glob;
aaec1fb
+      local_extglob = extended_glob;
aaec1fb
       extended_glob = 1;
aaec1fb
     }
aaec1fb
 #endif
aaec1fb
@@ -6546,7 +6546,7 @@ xparse_dolparen (base, string, indp, flags)
aaec1fb
 {
aaec1fb
   sh_parser_state_t ps;
aaec1fb
   sh_input_line_state_t ls;
aaec1fb
-  int orig_ind, nc, sflags, start_lineno;
aaec1fb
+  int orig_ind, nc, sflags, start_lineno, local_extglob;
aaec1fb
   char *ret, *ep, *ostring;
aaec1fb
 
aaec1fb
 /*debug_parser(1);*/
aaec1fb
@@ -6589,7 +6589,7 @@ xparse_dolparen (base, string, indp, flags)
aaec1fb
      old value will be restored by restore_parser_state(). */
aaec1fb
   expand_aliases = 0;
aaec1fb
 #if defined (EXTENDED_GLOB)
aaec1fb
-  global_extglob = extended_glob;		/* for reset_parser() */
aaec1fb
+  local_extglob = extended_glob;
aaec1fb
 #endif
aaec1fb
 
aaec1fb
   token_to_read = DOLPAREN;			/* let's trick the parser */
aaec1fb
@@ -6607,6 +6607,9 @@ xparse_dolparen (base, string, indp, flags)
aaec1fb
   restore_input_line_state (&ls);
aaec1fb
   restore_parser_state (&ps);
aaec1fb
 
aaec1fb
+#if defined (EXTENDED_GLOB)
aaec1fb
+  extended_glob = local_extglob;
aaec1fb
+#endif
aaec1fb
   token_to_read = 0;
aaec1fb
 
aaec1fb
   /* If parse_string returns < 0, we need to jump to top level with the
aaec1fb
@@ -7042,12 +7045,16 @@ cond_term ()
aaec1fb
 	}
aaec1fb
 
aaec1fb
       /* rhs */
aaec1fb
+#if defined (EXTENDED_GLOB)
aaec1fb
       local_extglob = extended_glob;
aaec1fb
       if (parser_state & PST_EXTPAT)
aaec1fb
 	extended_glob = 1;
aaec1fb
+#endif
aaec1fb
       tok = read_token (READ);
aaec1fb
+#if defined (EXTENDED_GLOB)
aaec1fb
       if (parser_state & PST_EXTPAT)
aaec1fb
 	extended_glob = local_extglob;
aaec1fb
+#endif
aaec1fb
       parser_state &= ~(PST_REGEXP|PST_EXTPAT);
aaec1fb
 
aaec1fb
       if (tok == WORD)
aaec1fb
@@ -7094,7 +7101,6 @@ parse_cond_command ()
aaec1fb
 {
aaec1fb
   COND_COM *cexp;
aaec1fb
 
aaec1fb
-  global_extglob = extended_glob;
aaec1fb
   cexp = cond_expr ();
aaec1fb
   return (make_cond_command (cexp));
aaec1fb
 }