Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 328503

Summary: linux-mod.eclass causing warning 'sed' called in global scope
Product: Gentoo Linux Reporter: email200202
Component: EclassesAssignee: Gentoo Kernel Bug Wranglers and Kernel Maintainers <kernel>
Status: RESOLVED INVALID    
Severity: normal    
Priority: High    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description email200202 2010-07-15 23:14:05 UTC
During emerge, I got the warning 'sed' called in global scope for packages using linux-mod.eclass.

Reproducible: Always

Steps to Reproduce:
1. emerge --sync
2. emerge -avuDN world

Actual Results:  
If you have packages using linux-mod.eclass, you get the above warning.


Expected Results:  
No warnings.

linux-mod.eclass is calling 'sed' at two lines:
sed -i 's:SUBDIRS=:M=:g' "${1}"
sed -i -e "/.*${CATEGORY}\/${PN}-${PVR}.*/d"

This is not in agreement with Gentoo Ebuild policy (http://www.gentoo.org/proj/en/devrel/handbook/handbook.xml?part=3&chap=1):
"An external application (such as grep, sed or awk) should never be called in global
scope for performance reasons, and alternatives such as using built-in bash
replacement should be used instead. Useful alternatives can be found in the Advanced
Bash Scripting Guide."
Comment 1 Mike Pagano gentoo-dev 2014-01-09 19:29:46 UTC
That line in the handbook actually refers to the ebuild policy.  sed is used ~122 times in all of our eclasses. I don't see this as a policy violation.
Comment 2 Tom Wijsman (TomWij) (RETIRED) gentoo-dev 2014-01-09 19:56:38 UTC
[QA]

They are inside a function; so, the eclass itself has no guarantee for it to be ran in global scope. If you however find an ebuild that calls these functions in global scope, feel free to let us know.
Comment 3 Mike Pagano gentoo-dev 2014-01-14 20:51:03 UTC
+  14 Jan 2014; Michael Pagano <mpagano@gentoo.org> linux-mod.eclass:
+  Remove use of sed in linux-mod.eclass. Replace with bash.
+
Comment 4 Mike Pagano gentoo-dev 2014-01-14 20:51:49 UTC
Missed the second spot. I will look at this next.
Comment 5 Mike Pagano gentoo-dev 2016-12-23 21:13:33 UTC
sed not called in global scope