hush: safe indention level by continueing a loop

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
hush: safe an indention level by continueing a loop

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
hush: cleanup coding style

General coding style cleanup

- add some blank lines
- add whitespaces on on both sides of operators

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
hush: remove bogus 'else'

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
hush: run_pipe_real must have num_progs == 1

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
hush: run_pipe_real: bail out early to safe an indention level

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
hush: remove quotes at end of processing

hush removes the quotes from strings too early. This leads to some bugs.
When hush executes

echo "hello sascha"

it correctly results in:

argv[0] = "echo"
argv[1] = "hello sascha"

However, the following behaves incorrect:

a="hello sascha"
echo "$a"

results in:

argv[0] = "echo"
argv[1] = "hello"
argv[2] = "sascha"

This is because hush removes the quotes and inserts variable values in a
single loop, so

echo "$a"

becomes:

echo hello sascha

after the loop.

Instead, keep the quotes until all variables are inserted and remove them
at the end.

This also fixes that echo \" resulted in \" instead of ".

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
hush: simplify globhack

hush used to escape '*' '[' '?' during parsing because the quotes
got removed in the first parsing loop.

globhack is used to remove these escapes again for glob. Since we now
keep the quotes until the end of parsing and we no longer escape glob
wildcards, we do no longer have to remove any quotes. With this globhack
can be much simpler.

While at it, change the prototype to match the one from glob() and rename
the function to fake_glob, because that's what it is: it just copies the
input string into the output struct without actually globbing.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
hush: pass GLOB_NOCHECK to glob

By doing so glob will not return GLOB_NOMATCH anymore but instead
just does what fake_glob would do.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
glob: activate GLOB_NOCHECK flag

Needed for hush.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
hush: Fix globbing

hush has a long standing and anoying glob bug. hush expands wildcards
during parsing of the script or command stream. When the command stream
begins to execute the wildcards are already expanded which leads to:

mkdir /tmp
cd /tmp
mkdir foo; ls *
ls: *: No such file or directory

To fix this expand wildcards right before executing the command. Since
'for' loops are not executed in commands, we have to keep the old behaviour
in here so that 'for i in *' still works.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
hush: allow to run interactive shell in do_sh

This allows to call 'sh' in scripts without arguments in which
case an interactive shell will be started.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
defaultenv: remove now unnecessary hush-hack

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
edit: Add proper screen size handling

We used to have a quite slow algorithm to detect the screen size
which was unused for long time. This patch changes this to first
set the cursor to x=999, y=999 and the read back the actual cursor
position. Since I am not confident that this works on all terminals
this is only used when edit is called as 'sedit'.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
remove dlmalloc.src

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
dhcp: set start time

The dhcp command starts with an unitialized start time. The start
time is often long in the past which results in an immediate timeout
and resend of the dhcp packet. Fix this by initializing the start time
correctly.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
tlsf_malloc: return valid pointer for malloc(0)

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Increase heapsize for i.MX21ADS board again.

Barebox cannot boot the recent mainline Linux kernels for the
i.MX21ADS board anymore when using TFTP, because the heap is too
small.

Signed-off-by: Jaccon Bastiaansen <jaccon.bastiaansen@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
netX: add a few base addresses for non on chip devices

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
netX: unify the device registration

Signed-off-by: Juergen Beisert <jbe@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>