script error

Sascha Hauer s.hauer at pengutronix.de
Tue Jun 8 02:49:29 EDT 2010


Hi Erwin,

Sorry for the delay.

On Thu, Jun 03, 2010 at 10:40:18PM +0200, Erwin Rol wrote:
> Hallo,
>
> i have a problem with running scripts. It seems that as soon a command  
> in a script fails the whole script is terminated.
>
> I am trying the following in /env/bin/init
>
> echo "Loading env A"
> mkdir /env_a/
> loadenv /dev/biosdisk0.1 /env_a/
> if [ -f /env_a/revision ]; then
>         . /env_a/revision
> fi
>
>
> The /dev/biosdisk0.1 is empty so the loadenv fails, and that also stops  
> the /env/bin/init script, everything after the "fi" is never executed.

That is because of the wrong exit code of loadenv. In do_loadenv we have

return envfs_load(filename, dirname);

which returns negative numbers as errors. The shell interpretes negative
numbers as return codes from commands as 'exit', so this should really be

return envfs_load(filename, dirname) ? 1 : 0;

Probably other commands have this bug aswell.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list