Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 555762 - sys-apps/baselayout: /etc/profile: support `set -u`
Summary: sys-apps/baselayout: /etc/profile: support `set -u`
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] baselayout (show other bugs)
Hardware: All Linux
: Normal enhancement (vote)
Assignee: William Hubbs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-07-24 07:15 UTC by Martin Väth
Modified: 2016-09-01 22:41 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Work with set -u and empty ROOTPATH (baselayout-setu.patch,871 bytes, patch)
2015-07-24 07:15 UTC, Martin Väth
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
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