2014-09-24 17:43:57 +02:00
|
|
|
diff -ur a/bash/builtins/common.h b/bash/builtins/common.h
|
|
|
|
--- a/bash/builtins/common.h 2010-05-31 00:31:51.000000000 +0200
|
|
|
|
+++ b/bash/builtins/common.h 2014-09-16 21:36:20.139826595 +0200
|
|
|
|
@@ -33,6 +33,8 @@
|
|
|
|
#define SEVAL_RESETLINE 0x010
|
|
|
|
#define SEVAL_PARSEONLY 0x020
|
2014-09-24 16:40:50 +02:00
|
|
|
#define SEVAL_NOLONGJMP 0x040
|
|
|
|
+#define SEVAL_FUNCDEF 0x080 /* only allow function definitions */
|
|
|
|
+#define SEVAL_ONECMD 0x100 /* only allow a single command */
|
2014-09-24 17:43:57 +02:00
|
|
|
|
|
|
|
/* Flags for describe_command, shared between type.def and command.def */
|
2014-09-24 16:40:50 +02:00
|
|
|
#define CDESC_ALL 0x001 /* type -a */
|
2014-09-24 17:43:57 +02:00
|
|
|
diff -ur a/bash/builtins/evalstring.c b/bash/builtins/evalstring.c
|
|
|
|
--- a/bash/builtins/evalstring.c 2010-11-23 14:22:15.000000000 +0100
|
|
|
|
+++ b/bash/builtins/evalstring.c 2014-09-16 21:36:20.139826595 +0200
|
|
|
|
@@ -261,6 +261,14 @@
|
2014-09-24 16:40:50 +02:00
|
|
|
{
|
|
|
|
struct fd_bitmap *bitmap;
|
|
|
|
|
|
|
|
+ if ((flags & SEVAL_FUNCDEF) && command->type != cm_function_def)
|
|
|
|
+ {
|
|
|
|
+ internal_warning ("%s: ignoring function definition attempt", from_file);
|
|
|
|
+ should_jump_to_top_level = 0;
|
|
|
|
+ last_result = last_command_exit_value = EX_BADUSAGE;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
bitmap = new_fd_bitmap (FD_BITMAP_SIZE);
|
|
|
|
begin_unwind_frame ("pe_dispose");
|
|
|
|
add_unwind_protect (dispose_fd_bitmap, bitmap);
|
2014-09-24 17:43:57 +02:00
|
|
|
@@ -321,6 +329,9 @@
|
2014-09-24 16:40:50 +02:00
|
|
|
dispose_command (command);
|
|
|
|
dispose_fd_bitmap (bitmap);
|
|
|
|
discard_unwind_frame ("pe_dispose");
|
|
|
|
+
|
|
|
|
+ if (flags & SEVAL_ONECMD)
|
|
|
|
+ break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2014-09-24 17:43:57 +02:00
|
|
|
diff -ur a/bash/variables.c b/bash/variables.c
|
|
|
|
--- a/bash/variables.c 2014-09-16 21:35:34.878850652 +0200
|
|
|
|
+++ b/bash/variables.c 2014-09-16 21:37:16.221034763 +0200
|
|
|
|
@@ -347,7 +347,11 @@
|
2014-09-24 16:40:50 +02:00
|
|
|
temp_string[char_index] = ' ';
|
|
|
|
strcpy (temp_string + char_index + 1, string);
|
|
|
|
|
|
|
|
- parse_and_execute (temp_string, name, SEVAL_NONINT|SEVAL_NOHIST);
|
2014-09-24 17:43:57 +02:00
|
|
|
+ /* Don't import function names that are invalid identifiers from the
|
|
|
|
+ environment, though we still allow them to be defined as shell
|
|
|
|
+ variables. */
|
|
|
|
+ if (legal_identifier (name))
|
|
|
|
+ parse_and_execute (temp_string, name, SEVAL_NONINT|SEVAL_NOHIST|SEVAL_FUNCDEF|SEVAL_ONECMD);
|
2014-09-24 16:40:50 +02:00
|
|
|
|
2014-09-24 17:43:57 +02:00
|
|
|
/* Ancient backwards compatibility. Old versions of bash exported
|
|
|
|
functions like name()=() {...} */
|
|
|
|
@@ -361,10 +365,6 @@
|
2014-09-24 16:40:50 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
report_error (_("error importing function definition for `%s'"), name);
|
|
|
|
-
|
|
|
|
- /* ( */
|
|
|
|
- if (name[char_index - 1] == ')' && name[char_index - 2] == '\0')
|
|
|
|
- name[char_index - 2] = '('; /* ) */
|
|
|
|
}
|
|
|
|
#if defined (ARRAY_VARS)
|
|
|
|
# if 0
|