Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.busybox.net/busybox.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2023-07-04 15:35:41 +0300
committerDenys Vlasenko <vda.linux@googlemail.com>2023-07-04 15:38:25 +0300
commit07a95cfcabb0706a22599b4440b495b6cfa8123e (patch)
treeee074cb7517d0d2673fb3563cbd19ed4f8e5ed40
parente5692e2342c68092ee3d4d895ea847cf7d13fa57 (diff)
ash: disable check for "good" function name, bash does not check this
function old new delta .rodata 105304 105261 -43 parse_command 1696 1633 -63 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-106) Total: -106 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-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)
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;
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)
|| 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;
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 @@
-readonly a=A
-readonly b=B
+readonly a='A'
+readonly b='B'
Ok:0
hush: a=A: readonly variable