summaryrefslogtreecommitdiffstats
path: root/scratch/variables-affix-3.1.patch.2
diff options
context:
space:
mode:
Diffstat (limited to 'scratch/variables-affix-3.1.patch.2')
-rw-r--r--scratch/variables-affix-3.1.patch.253
1 files changed, 53 insertions, 0 deletions
diff --git a/scratch/variables-affix-3.1.patch.2 b/scratch/variables-affix-3.1.patch.2
new file mode 100644
index 0000000..9ee9d6b
--- /dev/null
+++ b/scratch/variables-affix-3.1.patch.2
@@ -0,0 +1,53 @@
+diff -rupN bash-3.1-postpatch/variables.c bash-3.1/variables.c
+--- bash-3.1-postpatch/variables.c 2014-09-29 15:12:10.915662508 -0600
++++ bash-3.1/variables.c 2014-09-29 15:17:39.499385442 -0600
+@@ -308,28 +308,38 @@ initialize_shell_variables (env, privmod
+
+ /* If exported function, define it now. Don't import functions from
+ the environment in privileged mode. */
+- if (privmode == 0 && read_but_dont_execute == 0 && STREQN ("() {", string, 4))
+- {
+- string_length = strlen (string);
+- temp_string = (char *)xmalloc (3 + string_length + char_index);
++ if (privmode == 0 && read_but_dont_execute == 0
++ && STREQN (FUNCDEF_PREFIX, name, FUNCDEF_PREFIX_LEN)
++ && STREQ (name + char_index - FUNCDEF_SUFFIX_LEN, FUNCDEF_SUFFIX)
++ && STREQN ("() {", string, 4))
++ {
++ size_t name_length
++ = char_index - (FUNCDEF_PREFIX_LEN + FUNCDEF_SUFFIX_LEN);
++ char *temp_name = name + FUNCDEF_PREFIX_LEN;
++ /* Temporarily remove the suffix. */
++ temp_name[name_length] = '\0';
+
+- strcpy (temp_string, name);
+- temp_string[char_index] = ' ';
+- strcpy (temp_string + char_index + 1, string);
++ string_length = strlen (string);
++ temp_string = (char *)xmalloc (name_length + 1 + string_length + 1);
++ memcpy (temp_string, temp_name, name_length);
++ temp_string[name_length] = ' ';
++ memcpy (temp_string + name_length + 1, string, string_length + 1);
+
+ /* Don't import function names that are invalid identifiers from the
+ environment. */
+- if (legal_identifier (name))
+- parse_and_execute (temp_string, name, SEVAL_NONINT|SEVAL_NOHIST|SEVAL_FUNCDEF|SEVAL_ONECMD);
++ if (legal_identifier (temp_name))
++ parse_and_execute (temp_string, temp_name,
++ SEVAL_NONINT|SEVAL_NOHIST|SEVAL_FUNCDEF|SEVAL_ONECMD);
+
+- if (temp_var = find_function (name))
++ if (temp_var = find_function (temp_name))
+ {
+ VSETATTR (temp_var, (att_exported|att_imported));
+ array_needs_making = 1;
+ }
+ else
+ report_error (_("error importing function definition for `%s'"), name);
+-
++ /* Restore the original suffix. */
++ temp_name[name_length] = FUNCDEF_SUFFIX[0];
+ }
+ #if defined (ARRAY_VARS)
+ # if 0