Gentoo Archives: gentoo-dev

From: Alec Warner <antarus@g.o>
To: gentoo-dev@l.g.o
Subject: [gentoo-dev] QA checks merged into portage SVN
Date: Tue, 09 Jan 2007 00:55:58
Message-Id: 45A2E7A4.3010900@gentoo.org
1 Today I merged a set of QA checks into portage's trunk. I expect they
2 will be in ~arch whenever Zac gets around it ;)
3
4 The checks basically do a half-assed job of checking if crazy devs
5 change IFS or shopts in an ebuild, or an eclass, or a profile.bashrc.
6
7 These checks do NOT manage to check everywhere. Currently they print a
8 typical "QA Notice:" warning.
9
10 basically the logic is:
11
12 ebuild.sh -> Save IFS and shopts
13 call user/ebuild function
14 return to ebuild.sh
15 Check IFS and shopts and see if they are the same.
16
17 Obviously if you fanangle with IFS and then call some other bash func
18 there is no way to check for it and that random func may break.
19
20 The point of this check? Some pieces of code depend on default shell
21 options or a sane IFS. As an ebuild/eclass/profile author, you
22 shouldn't be messing with shell settings on a global scale as it may
23 affect other eclasses/profiles/ebuilds.
24
25 The correct way to mess with each is to save the old value (IFS) or
26 restore the previous setting (shopts).
27
28 local OLDIFS="$IFS"
29 ...do stuff
30 IFS="$OLDIFS"
31
32 set -s extglob
33 ...do stuff
34 set -u extglob
35
36 If you change a bunch of shell options or have no idea what you changed;
37 you can also do fun magic like:
38
39 local SHOPTS=$(shopt -p)
40 ..do stuff
41 eval "$SHOPTS"
42
43 which should restore the previous options.
44
45 Note: This check excludes the user's bashrc (/etc/portage/bashrc), so
46 mess with these things in there at your own risk.
47
48 Thanks,
49 -Alec Warner
50 --
51 gentoo-dev@g.o mailing list

Replies

Subject Author
Re: [gentoo-dev] QA checks merged into portage SVN Alec Warner <antarus@g.o>