U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] Handle environment variables like commands
@ 2008-10-15 10:09 Stefano Babic
  2008-10-15 10:45 ` Petri Lehtinen
  2008-10-15 10:57 ` Wolfgang Denk
  0 siblings, 2 replies; 12+ messages in thread
From: Stefano Babic @ 2008-10-15 10:09 UTC (permalink / raw)
  To: u-boot

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.

Signed-off-by : Stefano Babic <sbabic@denx.de>
---
 common/hush.c |    9 ++++++++-
 common/main.c |   37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 45 insertions(+), 1 deletions(-)

diff --git a/common/hush.c b/common/hush.c
index 093c428..68f8a6a 100644
--- 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 */
+			if ((p = getenv (child->argv[i])) != NULL )  {
+				int rcode;
+				rcode = (parse_string_outer(p,
+			                    FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP) != 0);
+				return rcode;
+			}
 
+			/* Look up command in command table */
 			if ((cmdtp = find_cmd(child->argv[i])) == NULL) {
 				printf ("Unknown command '%s' - try 'help'\n", child->argv[i]);
 				return -1;	/* give up after bad command */
diff --git a/common/main.c b/common/main.c
index c06ea07..b101b4f 100644
--- a/common/main.c
+++ b/common/main.c
@@ -1289,6 +1289,7 @@ int run_command (const char *cmd, int flag)
 	int argc, inquotes;
 	int repeatable = 1;
 	int rc = 0;
+	char *runenv;
 
 #ifdef DEBUG_PARSER
 	printf ("[RUN_COMMAND] cmd[%p]=\"", cmd);
@@ -1357,6 +1358,13 @@ int run_command (const char *cmd, int flag)
 			continue;
 		}
 
+		if ((runenv = getenv (argv[0])) != NULL )  {
+			if (run_command(runenv,flag) == -1) {
+				rc = -1;
+			}
+			continue;
+		}
+
 		/* Look up command in command table */
 		if ((cmdtp = find_cmd(argv[0])) == NULL) {
 			printf ("Unknown command '%s' - try 'help'\n", argv[0]);
@@ -1433,3 +1441,32 @@ int do_run (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 	return 0;
 }
 #endif
+
+int do_builtin (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
+{
+	int i;
+
+	if (argc < 2) {
+		printf ("Usage:\n%s\n", cmdtp->usage);
+		return 1;
+	}
+
+	/* Look up command in command table */
+	if ((cmdtp = find_cmd(argv[1])) == NULL) {
+		printf ("Unknown builtin command '%s' - try 'help'\n", argv[1]);
+		return 1;
+	}
+
+	/* Remove builtin from arg list */
+	argc--;
+
+	/* OK - call function to do the command */
+	if ((cmdtp->cmd) (cmdtp, flag, argc, &argv[1]) != 0) {
+		return 1;
+	}
+}
+
+U_BOOT_CMD(
+	builtin,	CFG_MAXARGS,	1,	do_builtin,
+	"builtin     - run builtin commands\n",
+);
-- 
1.5.4.3

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH] Handle environment variables like commands
  2008-10-15 10:09 [U-Boot] [PATCH] Handle environment variables like commands Stefano Babic
@ 2008-10-15 10:45 ` Petri Lehtinen
  2008-10-15 11:01   ` Wolfgang Denk
  2008-10-15 10:57 ` Wolfgang Denk
  1 sibling, 1 reply; 12+ messages in thread
From: Petri Lehtinen @ 2008-10-15 10:45 UTC (permalink / raw)
  To: u-boot

On Wed, Oct 15, 2008 at 12:09:44PM +0200, Stefano Babic 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.
> 
> Signed-off-by : Stefano Babic <sbabic@denx.de>
> ---

It seems to me that the "builtin" command itself can still be
redefined. Is this an issue?

-- 
Petri Lehtinen
Software Specialist
Inoi Oy
Tel. : +358 40 758 0229
Email: petri.lehtinen at inoi.fi

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH] Handle environment variables like commands
  2008-10-15 10:09 [U-Boot] [PATCH] Handle environment variables like commands Stefano Babic
  2008-10-15 10:45 ` Petri Lehtinen
@ 2008-10-15 10:57 ` Wolfgang Denk
  2008-10-15 11:56   ` stefano babic
  2008-10-15 12:09   ` Joakim Tjernlund
  1 sibling, 2 replies; 12+ messages in thread
From: Wolfgang Denk @ 2008-10-15 10:57 UTC (permalink / raw)
  To: u-boot

Dear Stefano,

In message <1224065384-24171-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.

Cool. That's just great.

If I had known it's suffcient to put ideas on  a  web  page  to  have
people  put  them  into  code  I  would  have started doing this much
earlier :-)

> +			/* Check if exists a variable with that name */
> +			if ((p = getenv (child->argv[i])) != NULL )  {
> +				int rcode;
> +				rcode = (parse_string_outer(p,
> +			                    FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP) != 0);
> +				return rcode;
> +			}

I think this covers only the hush shell version. We need something
like this instead:


#ifdef CFG_HUSH_PARSER
                rcode = parse_string_outer(p, FLAG_PARSE_SEMICOLON |
                                    FLAG_EXIT_FROM_LOOP);
#else 
                rcode =run_command (p, 0);
#endif


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
For every complex problem, there is a solution that is simple,  neat,
and wrong.                                               - Mark Twain

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH] Handle environment variables like commands
  2008-10-15 10:45 ` Petri Lehtinen
@ 2008-10-15 11:01   ` Wolfgang Denk
  2008-10-15 12:01     ` stefano babic
  0 siblings, 1 reply; 12+ messages in thread
From: Wolfgang Denk @ 2008-10-15 11:01 UTC (permalink / raw)
  To: u-boot

Dear Petri Lehtinen,

In message <20081015104550.GB6881@colossus> 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.
...
> It seems to me that the "builtin" command itself can still be
> redefined. Is this an issue?

Good catch. Yes, this must be prevented. Any variable named "builtin"
must be ignored here - i. e. we should issue  an  erro  when  someone
tries  a  "setenv", and ignore this variable explicitly (just in case
someone sneaks this into the default environment,  or  uses  un-fixed
Linux tools to create such a variable).

Thanks.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Objects in mirror are closer than they appear.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH] Handle environment variables like commands
  2008-10-15 10:57 ` Wolfgang Denk
@ 2008-10-15 11:56   ` stefano babic
  2008-10-15 12:26     ` Wolfgang Denk
  2008-10-15 12:09   ` Joakim Tjernlund
  1 sibling, 1 reply; 12+ messages in thread
From: stefano babic @ 2008-10-15 11:56 UTC (permalink / raw)
  To: u-boot

Wolfgang Denk wrote:

> If I had known it's suffcient to put ideas on  a  web  page  to  have
> people  put  them  into  code  I  would  have started doing this much
> earlier :-)

That's a good idea ;).

> I think this covers only the hush shell version. We need something
> like this instead:

This is not true, I think. The change you are talking about is in hush.c
 (so it must cover *only* the hush shell). The other change is in the
run_command() function and it is called when CFG_HUSH_PARSER is not
defined. So both cases are covered.

Best regards,
Stefano Babic


-- 
=====================================================================
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH] Handle environment variables like commands
  2008-10-15 11:01   ` Wolfgang Denk
@ 2008-10-15 12:01     ` stefano babic
  2008-10-15 12:25       ` Wolfgang Denk
  0 siblings, 1 reply; 12+ messages in thread
From: stefano babic @ 2008-10-15 12:01 UTC (permalink / raw)
  To: u-boot

Wolfgang Denk wrote:

> Good catch. Yes, this must be prevented. Any variable named "builtin"
> must be ignored here - i. e. we should issue  an  erro  when  someone
> tries  a  "setenv", and ignore this variable explicitly (just in case
> someone sneaks this into the default environment,  or  uses  un-fixed
> Linux tools to create such a variable).

I know, I wanted to know which is the preferred method to avoid that.
One way is to avoid to set the variable, as you suggest.
The other way is never execute a variable with the name "builtin" in the
command interpreter: "setenv builtin <something>" remains possible but
"builtin <command>" calls always the U-Boot commands.

Best regards,
Stefano Babic


-- 
stefano <stefano.babic@babic.homelinux.org>
GPG Key: 0x55814DDE
Fingerprint 4E85 2A66 4CBA 497A 2A7B D3BF 5973 F216 5581 4DDE

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH] Handle environment variables like commands
  2008-10-15 10:57 ` Wolfgang Denk
  2008-10-15 11:56   ` stefano babic
@ 2008-10-15 12:09   ` Joakim Tjernlund
  1 sibling, 0 replies; 12+ messages in thread
From: Joakim Tjernlund @ 2008-10-15 12:09 UTC (permalink / raw)
  To: u-boot

On Wed, 2008-10-15 at 12:57 +0200, Wolfgang Denk wrote:
> Dear Stefano,
> 
> In message <1224065384-24171-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.
> 
> Cool. That's just great.
> 
> If I had known it's suffcient to put ideas on  a  web  page  to  have
> people  put  them  into  code  I  would  have started doing this much
> earlier :-)
> 
> > +			/* Check if exists a variable with that name */
> > +			if ((p = getenv (child->argv[i])) != NULL )  {
> > +				int rcode;
> > +				rcode = (parse_string_outer(p,
> > +			                    FLAG_PARSE_SEMICOLON | FLAG_EXIT_FROM_LOOP) != 0);
> > +				return rcode;
> > +			}
> 
> I think this covers only the hush shell version. We need something
> like this instead:
> 
> 
> #ifdef CFG_HUSH_PARSER
>                 rcode = parse_string_outer(p, FLAG_PARSE_SEMICOLON |
>                                     FLAG_EXIT_FROM_LOOP);
> #else 
>                 rcode =run_command (p, 0);
> #endif

Move the parse_string_outer() into run_command() instead.

 Jocke

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH] Handle environment variables like commands
  2008-10-15 12:01     ` stefano babic
@ 2008-10-15 12:25       ` Wolfgang Denk
  0 siblings, 0 replies; 12+ messages in thread
From: Wolfgang Denk @ 2008-10-15 12:25 UTC (permalink / raw)
  To: u-boot

Dear Stefano,

In message <48F5DBB7.4070307@babic.homelinux.org> you wrote:
> Wolfgang Denk wrote:
> 
> > Good catch. Yes, this must be prevented. Any variable named "builtin"
> > must be ignored here - i. e. we should issue  an  erro  when  someone
> > tries  a  "setenv", and ignore this variable explicitly (just in case
> > someone sneaks this into the default environment,  or  uses  un-fixed
> > Linux tools to create such a variable).
> 
> I know, I wanted to know which is the preferred method to avoid that.
> One way is to avoid to set the variable, as you suggest.
> The other way is never execute a variable with the name "builtin" in the
> command interpreter: "setenv builtin <something>" remains possible but
> "builtin <command>" calls always the U-Boot commands.

We should do both: avoid that the variable gets set, and raise  error
messages  (both  in setenv() and in the fw_setenv Linux tool), but we
should also be defensive and never execute  it  if  we  run  into  it
(which  could  for  example  happen  if we're being poresented an old
environment where some user defined such a variable).

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
You said you  didn't  want  to  use  CGI.pm,  but  methinks  you  are
needlessly reinventing the wheel, one spoke at a time. Either you are
masochistic,  or  you  just haven't seen enough of what CGI.pm can do
for you. -- Randal L. Schwartz in <8cyb81rg81.fsf@gadget.cscaper.com>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH] Handle environment variables like commands
  2008-10-15 11:56   ` stefano babic
@ 2008-10-15 12:26     ` Wolfgang Denk
  0 siblings, 0 replies; 12+ messages in thread
From: Wolfgang Denk @ 2008-10-15 12:26 UTC (permalink / raw)
  To: u-boot

Dear Stefano,

In message <48F5DA6A.3090101@denx.de> you wrote:
> 
> > I think this covers only the hush shell version. We need something
> > like this instead:
> 
> This is not true, I think. The change you are talking about is in hush.c
>  (so it must cover *only* the hush shell). The other change is in the
> run_command() function and it is called when CFG_HUSH_PARSER is not
> defined. So both cases are covered.

You are right, of course. I read only part of the patch, it seems.
Sorry ...

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Faith: not *wanting* to know what is true."    - Friedrich Nietzsche

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH] Handle environment variables like commands
@ 2008-10-15 13:56 Stefano Babic
  2008-10-19 12:05 ` Wolfgang Denk
  0 siblings, 1 reply; 12+ messages in thread
From: Stefano Babic @ 2008-10-15 13:56 UTC (permalink / raw)
  To: u-boot

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
variable can be set with this name.

Signed-off-by : Stefano Babic <sbabic@denx.de>
---
 common/cmd_nvedit.c |    8 ++++++++
 common/hush.c       |    9 ++++++++-
 common/main.c       |   37 +++++++++++++++++++++++++++++++++++++
 tools/env/fw_env.c  |    8 ++++++++
 4 files changed, 61 insertions(+), 1 deletions(-)

diff --git a/common/cmd_nvedit.c b/common/cmd_nvedit.c
index 637d6c9..c6e4ec7 100644
--- a/common/cmd_nvedit.c
+++ b/common/cmd_nvedit.c
@@ -161,6 +161,14 @@ int _do_setenv (int flag, int argc, char *argv[])
 	}
 
 	/*
+	 * Check for reserved words
+	 */
+	if (strcmp(name, "builtin") == 0) {
+		printf ("## Error: builtin is a reserved word. You cannot set a variable with this name\n");
+		return 1;
+	}
+
+	/*
 	 * search if variable with this name already exists
 	 */
 	oldval = -1;
diff --git a/common/hush.c b/common/hush.c
index 093c428..bd7b223 100644
--- 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;
+			}
 
+			/* Look up command in command table */
 			if ((cmdtp = find_cmd(child->argv[i])) == NULL) {
 				printf ("Unknown command '%s' - try 'help'\n", child->argv[i]);
 				return -1;	/* give up after bad command */
diff --git a/common/main.c b/common/main.c
index c06ea07..d2be2ac 100644
--- a/common/main.c
+++ b/common/main.c
@@ -1289,6 +1289,7 @@ int run_command (const char *cmd, int flag)
 	int argc, inquotes;
 	int repeatable = 1;
 	int rc = 0;
+	char *runenv;
 
 #ifdef DEBUG_PARSER
 	printf ("[RUN_COMMAND] cmd[%p]=\"", cmd);
@@ -1357,6 +1358,13 @@ int run_command (const char *cmd, int flag)
 			continue;
 		}
 
+		if ((strcmp (argv[0], "builtin") != 0) && ((runenv = getenv (argv[0])) != NULL ))  {
+			if (run_command(runenv,flag) == -1) {
+				rc = -1;
+			}
+			continue;
+		}
+
 		/* Look up command in command table */
 		if ((cmdtp = find_cmd(argv[0])) == NULL) {
 			printf ("Unknown command '%s' - try 'help'\n", argv[0]);
@@ -1433,3 +1441,32 @@ int do_run (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
 	return 0;
 }
 #endif
+
+int do_builtin (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
+{
+	int i;
+
+	if (argc < 2) {
+		printf ("Usage:\n%s\n", cmdtp->usage);
+		return 1;
+	}
+
+	/* Look up command in command table */
+	if ((cmdtp = find_cmd(argv[1])) == NULL) {
+		printf ("Unknown builtin command '%s' - try 'help'\n", argv[1]);
+		return 1;
+	}
+
+	/* Remove builtin from arg list */
+	argc--;
+
+	/* OK - call function to do the command */
+	if ((cmdtp->cmd) (cmdtp, flag, argc, &argv[1]) != 0) {
+		return 1;
+	}
+}
+
+U_BOOT_CMD(
+	builtin,	CFG_MAXARGS,	1,	do_builtin,
+	"builtin     - run builtin commands\n",
+);
diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index 6e9c34f..cc31b79 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -353,6 +353,14 @@ int fw_setenv (int argc, char *argv[])
 	name = argv[1];
 
 	/*
+	 * Check for reserved words
+	 */
+	if (strcmp(name, "builtin") == 0) {
+		errno = EINVAL;
+		return -1;
+	}
+
+	/*
 	 * search if variable with this name already exists
 	 */
 	for (nxt = env = environment.data; *env; env = nxt + 1) {
-- 
1.5.4.3

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH] Handle environment variables like commands
  2008-10-15 13:56 Stefano Babic
@ 2008-10-19 12:05 ` Wolfgang Denk
  2008-10-20  7:50   ` stefano babic
  0 siblings, 1 reply; 12+ messages in thread
From: Wolfgang Denk @ 2008-10-19 12:05 UTC (permalink / raw)
  To: u-boot

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

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Marriage is the triumph  of  imagination  over  intelligence.  Second
marriage is the triumph of hope over experience.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [U-Boot] [PATCH] Handle environment variables like commands
  2008-10-19 12:05 ` Wolfgang Denk
@ 2008-10-20  7:50   ` stefano babic
  0 siblings, 0 replies; 12+ messages in thread
From: stefano babic @ 2008-10-20  7:50 UTC (permalink / raw)
  To: u-boot

Wolfgang Denk wrote:
> 
> 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.

yes, that is true ;(. Arguments are not passed to the underlying 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"

Ok, I understand. We need the same behavior as in the real shell to
perform this.

> 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.

I admit I have no better ideas...with positional parameters we can start
even some complex scripts. I take a look how to implement them, if there
are no other suggestions.

Best regards,
Stefano Babic


-- 
stefano <stefano.babic@babic.homelinux.org>
GPG Key: 0x55814DDE
Fingerprint 4E85 2A66 4CBA 497A 2A7B D3BF 5973 F216 5581 4DDE

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2008-10-20  7:50 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-15 10:09 [U-Boot] [PATCH] Handle environment variables like commands Stefano Babic
2008-10-15 10:45 ` Petri Lehtinen
2008-10-15 11:01   ` Wolfgang Denk
2008-10-15 12:01     ` stefano babic
2008-10-15 12:25       ` Wolfgang Denk
2008-10-15 10:57 ` Wolfgang Denk
2008-10-15 11:56   ` stefano babic
2008-10-15 12:26     ` Wolfgang Denk
2008-10-15 12:09   ` Joakim Tjernlund
  -- strict thread matches above, loose matches on Subject: below --
2008-10-15 13:56 Stefano Babic
2008-10-19 12:05 ` Wolfgang Denk
2008-10-20  7:50   ` stefano babic

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox