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

Tom Rini trini at konsulko.com
Mon Jul 5 21:53:45 CEST 2021


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?

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210705/63d7c652/attachment.sig>


More information about the U-Boot mailing list