[U-Boot-Users] improvement to setenv handling

Hi,
While setting-up an OMAP 5912 OSK, I experienced funny behavior with U-Boot's setenv command. The cause was that I was using an invalid syntax with an equal sign, i.e. setenv variable=value instead of setenv variable value
Apparently, nothing in U-Boot's code prevents from defining a variable with an equal in its name, but this cause strange behavious - see the examples below. In particular, pay attention to the fact that defining variable "a=b" cause existing variable "a" to be erased. The opposite is true also.
Would it be a fair limitation to impose that variable names can't contain an equal sign, and either accept my invalid syntax or report an error ?
Please note that this was tested with a binary image of U-Boot 1.1.1 as supplied by TI/Spectrum. I'd guess it also true on a stock 1.1.3, but I didn't test.
Any comments ?
Jean-Marc Ranger Ingénieur logiciel / Software Engineer SMIS R&D inc. 3100 Industriel Sherbrooke, Québec Canada J1L 1V8 Tel (819) 829-5120 ext 4242 Fax (819) 829-1133
U-Boot 1.1.1 (Jul 11 2005 - 15:47:28)
U-Boot code: 11080000 -> 11095D78 BSS: -> 1109A548 RAM Configuration: Bank #0: 10000000 32 MB Micron StrataFlash MT28F128J3 device initialized Flash: 32 MB In: serial Out: serial Err: serial Hit any key to stop autoboot: 0 OMAP5912 OSK # setenv a b OMAP5912 OSK # printenv baudrate=115200 ipaddr=156.117.97.156 serverip=156.117.97.139 netmask=255.255.254.0 bootargs=console=ttyS0,115200n8 noinitrd rw ip=off root=/dev/mtdblock4 mem=30M bootcmd=bootm 0x100000 bootfile=uImage bootdelay=10 stdin=serial stdout=serial stderr=serial a=b
Environment size: 260/131068 bytes OMAP5912 OSK # setenv a b=c OMAP5912 OSK # printenv baudrate=115200 ipaddr=156.117.97.156 serverip=156.117.97.139 netmask=255.255.254.0 bootargs=console=ttyS0,115200n8 noinitrd rw ip=off root=/dev/mtdblock4 mem=30M bootcmd=bootm 0x100000 bootfile=uImage bootdelay=10 stdin=serial stdout=serial stderr=serial a=b=c
Environment size: 262/131068 bytes OMAP5912 OSK # setenv a=b d OMAP5912 OSK # printenv baudrate=115200 ipaddr=156.117.97.156 serverip=156.117.97.139 netmask=255.255.254.0 bootargs=console=ttyS0,115200n8 noinitrd rw ip=off root=/dev/mtdblock4 mem=30M bootcmd=bootm 0x100000 bootfile=uImage bootdelay=10 stdin=serial stdout=serial stderr=serial a=b=d
Environment size: 262/131068 bytes OMAP5912 OSK # setenv a=b OMAP5912 OSK # printenv baudrate=115200 ipaddr=156.117.97.156 serverip=156.117.97.139 netmask=255.255.254.0 bootargs=console=ttyS0,115200n8 noinitrd rw ip=off root=/dev/mtdblock4 mem=30M bootcmd=bootm 0x100000 bootfile=uImage bootdelay=10 stdin=serial stdout=serial stderr=serial
Environment size: 256/131068 bytes OMAP5912 OSK # setenv a=b e OMAP5912 OSK # printenv baudrate=115200 ipaddr=156.117.97.156 serverip=156.117.97.139 netmask=255.255.254.0 bootargs=console=ttyS0,115200n8 noinitrd rw ip=off root=/dev/mtdblock4 mem=30M bootcmd=bootm 0x100000 bootfile=uImage bootdelay=10 stdin=serial stdout=serial stderr=serial a=b=e
Environment size: 262/131068 bytes OMAP5912 OSK # setenv a b=f OMAP5912 OSK # printenv baudrate=115200 ipaddr=156.117.97.156 serverip=156.117.97.139 netmask=255.255.254.0 bootargs=console=ttyS0,115200n8 noinitrd rw ip=off root=/dev/mtdblock4 mem=30M bootcmd=bootm 0x100000 bootfile=uImage bootdelay=10 stdin=serial stdout=serial stderr=serial a=b=f
Environment size: 262/131068 bytes OMAP5912 OSK #

In message 2D63750CB4594644B0372AC317B521CC5DB9C4@mtlexch04 you wrote:
While setting-up an OMAP 5912 OSK, I experienced funny behavior with U-Boot's setenv command. The cause was that I was using an invalid syntax with an equal sign, i.e. setenv variable=value instead of setenv variable value
This is not exactly invalid syntax. The first command is actually valid - it tries to delete the "variable=value" variable.
Would it be a fair limitation to impose that variable names can't contain an
Yes.
equal sign, and either accept my invalid syntax or report an error ?
Umm... actually this is what it already does: it accepts your syntax :-)
Best regards,
Wolfgang Denk
participants (2)
-
Ranger, Jean-Marc
-
Wolfgang Denk