
Dear Stefano Babic,
In message 1224078992-16173-1-git-send-email-sbabic@denx.de you wrote:
The command interpreter checks always if an environment variable for that name exists and in this case the content of the variable is executed. It becomes possible to redefine all U-Boot commands. A new "builtin" command is added to be able to run builtin U-boot commands even if they are redefined. For this reason, builtin is a reserved word an no environment
----------------------------------------------^^ and
variable can be set with this name.
...
--- a/common/hush.c +++ b/common/hush.c @@ -1677,9 +1677,16 @@ static int run_pipe_real(struct pipe *pi) child->argv[i]); return -1; }
/* Look up command in command table */
/* Check if exists a variable with that name, builtin is forbidden */
if ((strcmp (child->argv[i], "builtin") != 0) && (p = getenv (child->argv[i])) != NULL ) {
int rcode;
rcode = (parse_string_outer(p,
FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP) != 0);
return rcode;
}
We have a problem here.
Assume a simple test case like this:
=> setenv bootm 'echo Run bootm command; builtin bootm'
The idea of the extension is that something like
=> bootm ${kernel} ${fdt} ${ramdisk}
will still work.
Unfortunately, it doesn't, as we have no way to pass the arguments to the (substituted) command to the commands run in the executed script.
One idea to solve this problem would be to introduce positional parameters, similar to how it's being done in the shell. In the script, we could then refer to the original command args using "$1", "$2", ... so the example above would look like that:
=> setenv bootm 'echo Run bootm command; builtin bootm $1 $2 $3"
I have to admit that I didn't spend much thought on this yet, so all feedback or sugggestions of alternative / better ideas is welcome.
Best regards,
Wolfgang Denk