[RFC PATCH 02/28] cli: Add LIL shell

Sean Anderson seanga2 at gmail.com
Mon Jul 5 21:55:38 CEST 2021


On 7/5/21 3:53 PM, Tom Rini wrote:
> On Mon, Jul 05, 2021 at 03:47:47PM -0400, Sean Anderson wrote:
>> On 7/5/21 3:10 PM, Tom Rini wrote:
>>> On Sat, Jul 03, 2021 at 09:33:30PM +0200, Wolfgang Denk wrote:
>>>> Dear Sean,
>>>>
>>>> In message <8bbdb7a1-5085-a3b7-614f-12ae9aee8e8b at gmail.com> you wrote:
>>>>>
>>>>>> For a partial list, see
>>>>>>
>>>>>> [1] https://github.com/Forty-Bot/lil/commits/master
>>>>>
>>>>> Whoops, looks like I completely misread what you were asking here. I
>>>>> don't have an exhaustive list of differences, but here are some similar
>>>>> things expressed in both languages:
>>>>>
>>>>> sh				tcl
>>>>>
>>>>> foo=bar				set foo bar
>>>>> echo $foo			echo $foo
>>>>>
>>>>> if [ 1 -gt 2 ]; then		if {1 > 2} {
>>>>> 	echo a				echo a
>>>>> else				} {
>>>>> 	echo b				echo b
>>>>> fi				}
>>
>> The left side is possible with something like
>>
>> if itest 1 -gt 2; then # etc.
>>
>>>>>
>>>>> foo() {				proc foo {first second} {
>>>>> 	echo $1 $2			echo $first $second
>>>>> }				}
>>
>> This is not possible. We only have eval (run) as of today. I view adding
>> functions as one of the most important usability improvements we can
>> make.
>>
>>>>>
>>>>> for file in $(ls *.c); do	foreach file [glob *.c] {
>>>>> 	echo $file			echo $file
>>>>> done				}
>>
>> This is possible only if you already have a list of files. For example,
>> one could do
>>
>> part list mmc 0 -bootable parts
>> for p in $parts; do #etc
>>
>> but the part command is one of the only ones which produces output in
>> the correct format. If you want to (e.g.) dynamically construct a list
>> you will have a much harder time.
>>
>>>>> fact() {
>>>>> 	if [ $1 -eq 0 ]; then
>>>>> 		echo 1
>>>>> 	else
>>>>> 		echo $(($1 * $(fact $(($1 - 1)))))
>>>>> 	fi
>>>>> }
>>
>> This is technically possible with run and setexpr, but fairly cumbersome
>> to do.
>>
>>>>>
>>>>> 				proc fact {n} {
>>>>> 					if {$n} {
>>>>> 						expr {$n * [fact [expr {$n - 1}]]}
>>>>> 					} {
>>>>> 						return 1
>>>>> 					}
>>>>> 				}
>>>>>
>>>>> Hopefully this gives you a bit of a feel for the basic differences.
>>>
>>> Which of these things, from each column, can you do in the context of
>>> U-Boot?  That's important too.
>>
>> See above.
> 
> And for clarity, on the LIL side, with a few things like needing to
> bring in the list of files somehow, all of those would work in U-Boot?
> 

Correct. The only unimplemented function is "glob".

--Sean


More information about the U-Boot mailing list