Summary: | sys-apps/baselayout: /etc/profile: support `set -u` | ||
---|---|---|---|
Product: | Gentoo Linux | Reporter: | Martin Väth <martin> |
Component: | [OLD] baselayout | Assignee: | 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 |
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. Thanks |
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.