Re: [U-Boot] strange behaviors with setexpr syntax error and '==' != '-eq"

2017-09-26 Thread Clément Péron
Dear Wolfgang Denk,

Thanks a lot for your explanations !
Clement

> I'm tempted to rephrase: you made some errors :-)


>> The first one is when I try to do a mask from a memory address and
>> store it to an env variable.
>>
>> => setexpr toto *{loadaddr} & 0xFF
>> syntax error
>> => setexpr toto *{loadaddr} & 0x3F
>> syntax error
>> => setexpr toto  0x3F & *{loadaddr}
>> syntax error
>
> This has nothing to dowith the setexpr command - the error message
> comes from the shell.  It will issue the same error for other uses
> of an (unmasked) ampersand:
>
> ->  echo a & echo b
> syntax error
>
>
> Note: you must always escape special characters.
>
> Also, you probably want to write ${loadaddr} (mind the dollar
> character).
>
> So try:
>
> setexpr toto *${loadaddr} '&' 0xFF
>
>> The second one is the difference between '==' and '-eq'
>>
>> => setenv a 1
>> => setenv b 2
>> => if test ${a} -eq ${b}; then echo toto; fi;
>> => if test ${a} == ${b}; then echo toto; fi;
>> toto
>>
>> Which doesn't seem logic.
>
> Well, did you read the man page for the test command?
>
> == is operating on STRING arguments, while -eq is operating on
> INTEGER arguments.  So depending on the content of your variables
> the result may be the same or different.
>
>
>
> Best regards,
>
> Wolfgang Denk
>
> --
> DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
> HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
> Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
> COBOL is for morons. -- E.W. Dijkstra
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] strange behaviors with setexpr syntax error and '==' != '-eq"

2017-09-26 Thread Wolfgang Denk
Dear Clément Péron,

In message  
you wrote:
> 
> I write a script on u-boot but i found 2 strange behaviors.

I'm tempted to rephrase: you made some errors :-)

> The first one is when I try to do a mask from a memory address and
> store it to an env variable.
> 
> => setexpr toto *{loadaddr} & 0xFF
> syntax error
> => setexpr toto *{loadaddr} & 0x3F
> syntax error
> => setexpr toto  0x3F & *{loadaddr}
> syntax error

This has nothing to dowith the setexpr command - the error message
comes from the shell.  It will issue the same error for other uses
of an (unmasked) ampersand:

->  echo a & echo b
syntax error


Note: you must always escape special characters.

Also, you probably want to write ${loadaddr} (mind the dollar
character).

So try:

setexpr toto *${loadaddr} '&' 0xFF

> The second one is the difference between '==' and '-eq'
> 
> => setenv a 1
> => setenv b 2
> => if test ${a} -eq ${b}; then echo toto; fi;
> => if test ${a} == ${b}; then echo toto; fi;
> toto
> 
> Which doesn't seem logic.

Well, did you read the man page for the test command?

== is operating on STRING arguments, while -eq is operating on
INTEGER arguments.  So depending on the content of your variables
the result may be the same or different.



Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: w...@denx.de
COBOL is for morons. -- E.W. Dijkstra
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] strange behaviors with setexpr syntax error and '==' != '-eq"

2017-09-26 Thread Clément Péron
Hi,

I write a script on u-boot but i found 2 strange behaviors.

The first one is when I try to do a mask from a memory address and
store it to an env variable.

=> setexpr toto *{loadaddr} & 0xFF
syntax error
=> setexpr toto *{loadaddr} & 0x3F
syntax error
=> setexpr toto  0x3F & *{loadaddr}
syntax error

The second one is the difference between '==' and '-eq'

=> setenv a 1
=> setenv b 2
=> if test ${a} -eq ${b}; then echo toto; fi;
=> if test ${a} == ${b}; then echo toto; fi;
toto

Which doesn't seem logic.

Could you please explain me these behaviors ?

Thanks,
Clement
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot