With ash as login shell one get: -- /etc/profile.d/java-config-2.sh: 14: [[: not found -- Reproducible: Always
Is changing [[ ]] to [ ] enough to make it compliant?
> Is changing [[ ]] to [ ] enough to make it compliant? I don't think so. That leads to problems in case $UID is empty. Should be sth. like: -- if [ "${UID}" != 0 -a -L "${gentoo_user_vm}" ]; then export JAVA_HOME=${gentoo_user_vm} # Otherwise set to the current system vm elif [ -L /etc/java-config-2/current-system-vm ]; then export JAVA_HOME=${gentoo_system_vm} fi --
(In reply to comment #2) > > Is changing [[ ]] to [ ] enough to make it compliant? > > I don't think so. That leads to problems in case $UID is empty. Should be sth. > like: > > -- > if [ "${UID}" != 0 -a -L "${gentoo_user_vm}" ]; then > export JAVA_HOME=${gentoo_user_vm} > # Otherwise set to the current system vm > elif [ -L /etc/java-config-2/current-system-vm ]; then > export JAVA_HOME=${gentoo_system_vm} > fi > -- > The best way to get this fixed is to submit a patch.
Created attachment 113153 [details, diff] POSIX compliance for /etc/profile.d/java-config-2.sh
> The best way to get this fixed is to submit a patch. Ok, but I'm not a shell programmer...
Works For Me BTW, $UID itself is a bashism. If $UID is blank you may wish to consider using the id program depending on how anal you want this to be. If it was me, I would just check the link in $HOME
(In reply to comment #6) > Works For Me > > BTW, $UID itself is a bashism. If $UID is blank you may wish to consider using > the id program depending on how anal you want this to be. > > If it was me, I would just check the link in $HOME > No, because the root user always uses the system vm.
Created attachment 113463 [details, diff] Use id -u if UID is unset Uberlord: This patch should be fine then, but is id -u available on BSD for example?
(In reply to comment #8) > Created an attachment (id=113463) [edit] > Use id -u if UID is unset > > Uberlord: This patch should be fine then, but is id -u available on BSD for > example? I would also check that the id binary is available, as it's in /usr which may or may not be available. This script will be run in single use mode, hence there will be times when it's not. if [ -z "${UID}" ] ; then if type id >/dev/null 2>/dev/null ; then UID=$(id -u) else [ "${USER}" = "root" ] && UID=0 fi fi OK, so the last test sucks, but it's the only thing I can think of.
Fixed in 2.0.31-r5. Thanks Karl, Uberlord and drizztbsd.