FAI ainsl exit code, softupdate, scripts/FAIBASE/10-misc
Rob
rclemley at booksys.com
Tue May 25 00:11:07 CEST 2010
This is not a show-stopper, but I am curious to find the thoughts of
users and developers about this behavior. I've searched the website and
archives and I generally DO follow the email list, but I haven't heard
of this topic before. First, a real problem is the ainsl manpage,
which doesn't document the exit codes of the ainsl command. Second, I
differ philosophically with the idea of ainsl returning an error code to
the caller if the line already exists in the file.
My actual questions are: What's the best way to have
scripts/FAIBASE/10-misc return success on softupdate? Should the
module list be checked on every softupdate? Whether or not, I think
extra logic would be needed in 10-misc to avoid reporting errors when in
fact no errors exist. (To be idealistic, I would like to see ainsl
return 0 if the line previously existed in the file.)
Details:
When running softupdate, scripts/FAIBASE/10-misc always reports an error.
It appears this is because, at the beginning of the script, these
commands are issued:
error=0 ; trap "error=$((error|1))" ERR
which causes the script to return non-zero (error condition) whenever a
simple command in the script returns non-zero. Next, the 10-misc script
uses ainsl to check /etc/modules:
for module in $MODULESLIST; do
ainsl -a $target/etc/modules "^$module$"
done
Upon softupdate, the modules should already be in the file, which causes
the $error variable to be set, which is then returned as an exit code.
This is because ainsl returns an error (1) if the line is already in the
file [code from ainsl]:
exit 1 if $found; # nothing to append
which returns an error condition if the file is already in the desired
state. (This doesn't seem intuitively correct to me. My intent is to
ensure the line is in the file, I don't care if the line existed before
or not). Because of this behavior of ainsl and the error trapping code
in 10-misc, 10-misc always reports an error on softupdate.
The return values of ainsl are not documented on the ainsl manpage.
Thank you for FAI and your help and ideas!
Rob
More information about the linux-fai
mailing list