Today I merged a set of QA checks into portage's trunk.  I expect they
will be in ~arch whenever Zac gets around it ;)

The checks basically do a half-assed job of checking if crazy devs
change IFS or shopts in an ebuild, or an eclass, or a profile.bashrc.

These checks do NOT manage to check everywhere.  Currently they print a
typical "QA Notice:" warning.

basically the logic is:

ebuild.sh -> Save IFS and shopts
call user/ebuild function
return to ebuild.sh
Check IFS and shopts and see if they are the same.

Obviously if you fanangle with IFS and then call some other bash func
there is no way to check for it and that random func may break.

The point of this check?  Some pieces of code depend on default shell
options or a sane IFS.  As an ebuild/eclass/profile author, you
shouldn't be messing with shell settings on a global scale as it may
affect other eclasses/profiles/ebuilds.

The correct way to mess with each is to save the old value (IFS) or
restore the previous setting (shopts).

local OLDIFS="$IFS"
...do stuff
IFS="$OLDIFS"

set -s extglob
...do stuff
set -u extglob

If you change a bunch of shell options or have no idea what you changed;
you can also do fun magic like:

local SHOPTS=$(shopt -p)
..do stuff
eval "$SHOPTS"

which should restore the previous options.

Note: This check excludes the user's bashrc (/etc/portage/bashrc), so
mess with these things in there at your own risk.

Thanks,
-Alec Warner
-- 
[email protected] mailing list

Reply via email to