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

Bug 555762

Summary: sys-apps/baselayout: /etc/profile: support `set -u`
Product: Gentoo Linux Reporter: Martin Väth <martin>
Component: [OLD] baselayoutAssignee: William Hubbs <williamh>
Status: RESOLVED FIXED    
Severity: enhancement CC: base-system
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---
Attachments: Work with set -u and empty ROOTPATH

Description Martin Väth 2015-07-24 07:15:00 UTC
Created attachment 407496 [details, diff]
Work with set -u and empty ROOTPATH

If /etc/profile is sourced from a non-bash shell with set -u, it will die, because it expects certain bash-only parameter to exist.

Please consider avoiding this, since "set -u" is the only possibility of (sort of) strict syntax checking in shell scripts.

A way to avoid it is to use ${VAR-} instead of $VAR for possibly unset variables.

The attached patch does this.

Additionally, this patch avoids adding ":" to PATH if {ROOT,}PATH is unset or empty: Adding ":" would be equivalent to adding ":." which is a bad idea in view of security consideration.
Comment 1 William Hubbs gentoo-dev 2016-09-01 21:50:10 UTC
This was accepted in commit 89f852f and is included in 2.3.
However, we really can't say that the distro supports set -u in its
startup files officially because of things like /etc/profile.d.
Comment 2 Martin Väth 2016-09-01 22:41:32 UTC
Thanks