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-12ae9aee8...@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.
--Sean