public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] QA checks merged into portage SVN
@ 2007-01-09  0:53 Alec Warner
  2007-01-09  6:08 ` Alec Warner
  0 siblings, 1 reply; 3+ messages in thread
From: Alec Warner @ 2007-01-09  0:53 UTC (permalink / raw
  To: gentoo-dev

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
-- 
gentoo-dev@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [gentoo-dev] QA checks merged into portage SVN
  2007-01-09  0:53 [gentoo-dev] QA checks merged into portage SVN Alec Warner
@ 2007-01-09  6:08 ` Alec Warner
  2007-01-09 22:24   ` Alec Warner
  0 siblings, 1 reply; 3+ messages in thread
From: Alec Warner @ 2007-01-09  6:08 UTC (permalink / raw
  To: gentoo-dev

Alec Warner wrote:
> 
> 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, the examples above could be improved by prefixing your variables
(you don't want global collisions, trust me)

So fex KDE_SHOPTS or KDE_OLD_IFS instead of just OLD_IFS.

> Thanks,
> -Alec Warner

-- 
gentoo-dev@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [gentoo-dev] QA checks merged into portage SVN
  2007-01-09  6:08 ` Alec Warner
@ 2007-01-09 22:24   ` Alec Warner
  0 siblings, 0 replies; 3+ messages in thread
From: Alec Warner @ 2007-01-09 22:24 UTC (permalink / raw
  To: gentoo-dev

Alec Warner wrote:
> Note, the examples above could be improved by prefixing your variables
> (you don't want global collisions, trust me)
> 
> So fex KDE_SHOPTS or KDE_OLD_IFS instead of just OLD_IFS.
> 

And as Caster pointed out on irc, this is only a problem if a local var
won't cut it; a local should work for most cases I think (but not
versionator.eclass, which I'm attempting to fix soon).

-Alec
-- 
gentoo-dev@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-01-09 22:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-09  0:53 [gentoo-dev] QA checks merged into portage SVN Alec Warner
2007-01-09  6:08 ` Alec Warner
2007-01-09 22:24   ` Alec Warner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox