public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] using ${var} with env import
@ 2011-03-30  8:20 Holger Brunck
  2011-03-30 12:57 ` Wolfgang Denk
  0 siblings, 1 reply; 3+ messages in thread
From: Holger Brunck @ 2011-03-30  8:20 UTC (permalink / raw)
  To: u-boot

Hi all,
I am using env import -t to import environment variables from a textfile.

My simple textfile is:
fdt_file=${hostname}/${hostname}.dtb

I import the file with:
=> tftp 200000 scripts/my_environ.txt
=> env import -t 200000 ${filesize}

Now when I print the variable I get:
=> print fdt_file
fdt_file=${hostname}/${hostname}.dtb

hostname is defined as:
=> print hostname
hostname=mgcoge

I see that the ${hostname} for my fdt_file variable is not replaced. If I do
this with setenv:
=> setenv fdt_file_2 ${hostname}/${hostname}.dtb
=> print fdt_file_2
fdt_file_2=mgcoge/mgcoge.dtb

My variable is replaced.

Is the usage of ${var} in the textfiles not possible? Or is there a way to solve
this problem?

I try to use this textfile for different boards and can therfore not specify
hostname in advance in the textfile.

Best regards
Holger Brunck

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

* [U-Boot] using ${var} with env import
  2011-03-30  8:20 [U-Boot] using ${var} with env import Holger Brunck
@ 2011-03-30 12:57 ` Wolfgang Denk
  2011-03-30 15:41   ` Holger Brunck
  0 siblings, 1 reply; 3+ messages in thread
From: Wolfgang Denk @ 2011-03-30 12:57 UTC (permalink / raw)
  To: u-boot

Dear Holger Brunck,

In message <4D92E7B4.9010305@keymile.com> you wrote:
>
> I am using env import -t to import environment variables from a textfile.
> 
> My simple textfile is:
> fdt_file=${hostname}/${hostname}.dtb
> 
> I import the file with:
> => tftp 200000 scripts/my_environ.txt
> => env import -t 200000 ${filesize}
> 
> Now when I print the variable I get:
> => print fdt_file
> fdt_file=${hostname}/${hostname}.dtb
> 
> hostname is defined as:
> => print hostname
> hostname=mgcoge

This is perfectly normal. "env export" and "env import" are inverse
operations - they export and import the environment data directly,
without any conversions (except for the formatting as text lines
versus NUL-terminated strings).  Neither of these functions performs
any variable substitutions - these are done in the command
interpreter, i. e. when you run a command in the shell.

> Is the usage of ${var} in the textfiles not possible? Or is there a way to solve
> this problem?

I understand that with "usage of ${var}" you mean variable subsitution
- this is indeed not supposed to happen during an "env import".

I don't consider this a problem, though.  If you want such
substituion, use the defined strings in shell commands.

Actually I consider it more clever to _keep_ the ${hostname} stuff in
your variable definitions, as then it is sufficient to change the
"hostname" variable to take affect everywhere; if you subsitute the
value hard in other variables, you would have to fix all of these (and
provide code to do so).

So actually I think this is not a problem, it just points out some
inefficient usage of the environment in your setup.

> I try to use this textfile for different boards and can therfore not specify
> hostname in advance in the textfile.

You don't have to. It does not matter when it gets defined (as long as
the variables referencing it are not needed before that).

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
Genitiv ins Wasser, weil's Dativ ist!

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

* [U-Boot] using ${var} with env import
  2011-03-30 12:57 ` Wolfgang Denk
@ 2011-03-30 15:41   ` Holger Brunck
  0 siblings, 0 replies; 3+ messages in thread
From: Holger Brunck @ 2011-03-30 15:41 UTC (permalink / raw)
  To: u-boot

Hello,

Wolfgang Denk wrote:
> Dear Holger Brunck,
> 
> In message <4D92E7B4.9010305@keymile.com> you wrote:
>> I am using env import -t to import environment variables from a textfile.
>>
>> My simple textfile is:
>> fdt_file=${hostname}/${hostname}.dtb
>>
>> I import the file with:
>> => tftp 200000 scripts/my_environ.txt
>> => env import -t 200000 ${filesize}
>>
>> Now when I print the variable I get:
>> => print fdt_file
>> fdt_file=${hostname}/${hostname}.dtb
>>
>> hostname is defined as:
>> => print hostname
>> hostname=mgcoge
> 
> This is perfectly normal. "env export" and "env import" are inverse
> operations - they export and import the environment data directly,
> without any conversions (except for the formatting as text lines
> versus NUL-terminated strings).  Neither of these functions performs
> any variable substitutions - these are done in the command
> interpreter, i. e. when you run a command in the shell.
> 
>> Is the usage of ${var} in the textfiles not possible? Or is there a way to solve
>> this problem?
> 
> I understand that with "usage of ${var}" you mean variable subsitution
> - this is indeed not supposed to happen during an "env import".
> 
> I don't consider this a problem, though.  If you want such
> substituion, use the defined strings in shell commands.
> 
> Actually I consider it more clever to _keep_ the ${hostname} stuff in
> your variable definitions, as then it is sufficient to change the
> "hostname" variable to take affect everywhere; if you subsitute the
> value hard in other variables, you would have to fix all of these (and
> provide code to do so).
> 
> So actually I think this is not a problem, it just points out some
> inefficient usage of the environment in your setup.
> 

yes you are right and the problem I had was at a different place.

Sorry for the noise.

Best regards
Holger Brunck

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

end of thread, other threads:[~2011-03-30 15:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-30  8:20 [U-Boot] using ${var} with env import Holger Brunck
2011-03-30 12:57 ` Wolfgang Denk
2011-03-30 15:41   ` Holger Brunck

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