script error
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.
any ideas ?
- Erwin
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Hi Erwin,
Quoted 5 lines · Erwin Rol
i have a problem with running scripts. It seems that as soon a command in a script fails the whole script is terminated.
any ideas ?
I met the same problem in init yesterday. I didn't yet had time to investigate more.
Eric
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Hi Erwin,
Sorry for the delay.
Quoted 15 lines · Erwin Rol
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
Quoted 2 lines
The
/dev/biosdisk0.1is 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
Signature · 9 lines
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 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox