← Commit list

07a95cfca

Denys Vlasenko
Denys Vlasenko
2023-07-04
SUCCESS Duration: 152s

Subject

ash: disable check for "good" function name, bash does not check this

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

shell/ash.c+9 -8
@@ -12123,18 +12123,19 @@ simplecmd(void)
if (args && app == &args->narg.next
&& !vars && !redir
) {
- struct builtincmd *bcmd;
- const char *name;
+// struct builtincmd *bcmd;
+// const char *name;
/* We have a function */
if (IF_BASH_FUNCTION(!function_flag &&) readtoken() != TRP)
raise_error_unexpected_syntax(TRP);
- name = n->narg.text;
- if (!goodname(name)
- || ((bcmd = find_builtin(name)) && IS_BUILTIN_SPECIAL(bcmd))
- ) {
- raise_error_syntax("bad function name");
- }
+//bash allows functions named "123", "..", "return"!
+// name = n->narg.text;
+// if (!goodname(name)
+// || ((bcmd = find_builtin(name)) && IS_BUILTIN_SPECIAL(bcmd))
+// ) {
+// raise_error_syntax("bad function name");
+// }
n->type = NDEFUN;
checkkwd = CHKNL | CHKKWD | CHKALIAS;
n->ndefun.text = n->narg.text;
shell/hush.c+6 -1
@@ -4306,7 +4306,7 @@ static int done_word(struct parse_context *ctx)
|| endofname(command->argv[0])[0] != '\0'
) {
/* bash says just "not a valid identifier" */
- syntax_error("bad variable name in for");
+ syntax_error("bad for loop variable");
return 1;
}
/* Force FOR to have just one word (variable name) */
@@ -4683,6 +4683,11 @@ static int parse_group(struct parse_context *ctx,
syntax_error_unexpected_ch(ch);
return -1;
}
+//bash allows functions named "123", "..", "return"!
+// if (endofname(command->argv[0])[0] != '\0') {
+// syntax_error("bad function name");
+// return -1;
+// }
nommu_addchr(&ctx->as_string, ch);
command->cmd_type = CMD_FUNCDEF;
goto skip;
shell/hush_test/hush-vars/readonly0.right+2 -2
@@ -1,5 +1,5 @@
-readonly a=A
-readonly b=B
+readonly a='A'
+readonly b='B'
Ok:0
hush: a=A: readonly variable