aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--shell/ash.c17
-rw-r--r--shell/hush.c7
-rw-r--r--shell/hush_test/hush-vars/readonly0.right4
3 files changed, 17 insertions, 11 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 96d2433d3..e91566994 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -12123,18 +12123,19 @@ simplecmd(void)
12123 if (args && app == &args->narg.next 12123 if (args && app == &args->narg.next
12124 && !vars && !redir 12124 && !vars && !redir
12125 ) { 12125 ) {
12126 struct builtincmd *bcmd; 12126// struct builtincmd *bcmd;
12127 const char *name; 12127// const char *name;
12128 12128
12129 /* We have a function */ 12129 /* We have a function */
12130 if (IF_BASH_FUNCTION(!function_flag &&) readtoken() != TRP) 12130 if (IF_BASH_FUNCTION(!function_flag &&) readtoken() != TRP)
12131 raise_error_unexpected_syntax(TRP); 12131 raise_error_unexpected_syntax(TRP);
12132 name = n->narg.text; 12132//bash allows functions named "123", "..", "return"!
12133 if (!goodname(name) 12133// name = n->narg.text;
12134 || ((bcmd = find_builtin(name)) && IS_BUILTIN_SPECIAL(bcmd)) 12134// if (!goodname(name)
12135 ) { 12135// || ((bcmd = find_builtin(name)) && IS_BUILTIN_SPECIAL(bcmd))
12136 raise_error_syntax("bad function name"); 12136// ) {
12137 } 12137// raise_error_syntax("bad function name");
12138// }
12138 n->type = NDEFUN; 12139 n->type = NDEFUN;
12139 checkkwd = CHKNL | CHKKWD | CHKALIAS; 12140 checkkwd = CHKNL | CHKKWD | CHKALIAS;
12140 n->ndefun.text = n->narg.text; 12141 n->ndefun.text = n->narg.text;
diff --git a/shell/hush.c b/shell/hush.c
index ec4f3a2f2..1b7e546fa 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -4306,7 +4306,7 @@ static int done_word(struct parse_context *ctx)
4306 || endofname(command->argv[0])[0] != '\0' 4306 || endofname(command->argv[0])[0] != '\0'
4307 ) { 4307 ) {
4308 /* bash says just "not a valid identifier" */ 4308 /* bash says just "not a valid identifier" */
4309 syntax_error("bad variable name in for"); 4309 syntax_error("bad for loop variable");
4310 return 1; 4310 return 1;
4311 } 4311 }
4312 /* Force FOR to have just one word (variable name) */ 4312 /* Force FOR to have just one word (variable name) */
@@ -4683,6 +4683,11 @@ static int parse_group(struct parse_context *ctx,
4683 syntax_error_unexpected_ch(ch); 4683 syntax_error_unexpected_ch(ch);
4684 return -1; 4684 return -1;
4685 } 4685 }
4686//bash allows functions named "123", "..", "return"!
4687// if (endofname(command->argv[0])[0] != '\0') {
4688// syntax_error("bad function name");
4689// return -1;
4690// }
4686 nommu_addchr(&ctx->as_string, ch); 4691 nommu_addchr(&ctx->as_string, ch);
4687 command->cmd_type = CMD_FUNCDEF; 4692 command->cmd_type = CMD_FUNCDEF;
4688 goto skip; 4693 goto skip;
diff --git a/shell/hush_test/hush-vars/readonly0.right b/shell/hush_test/hush-vars/readonly0.right
index 8b750eb5f..7599698d2 100644
--- a/shell/hush_test/hush-vars/readonly0.right
+++ b/shell/hush_test/hush-vars/readonly0.right
@@ -1,5 +1,5 @@
1readonly a=A 1readonly a='A'
2readonly b=B 2readonly b='B'
3Ok:0 3Ok:0
4 4
5hush: a=A: readonly variable 5hush: a=A: readonly variable