Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 169925 - java-config-2.sh not "sh compliant"
Summary: java-config-2.sh not "sh compliant"
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Unspecified (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Java team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-03-08 12:03 UTC by Karl Schulz
Modified: 2007-03-16 11:12 UTC (History)
2 users (show)

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


Attachments
POSIX compliance for /etc/profile.d/java-config-2.sh (java-config-2.sh.diff,719 bytes, patch)
2007-03-13 10:32 UTC, Karl Schulz
Details | Diff
Use id -u if UID is unset (java-config-2.posix,1.02 KB, patch)
2007-03-16 10:45 UTC, Petteri Räty (RETIRED)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Karl Schulz 2007-03-08 12:03:17 UTC
With ash as login shell one get:
--
/etc/profile.d/java-config-2.sh: 14: [[: not found
--

Reproducible: Always
Comment 1 Vlastimil Babka (Caster) (RETIRED) gentoo-dev 2007-03-13 01:48:35 UTC
Is changing [[ ]] to [ ] enough to make it compliant?
Comment 2 Karl Schulz 2007-03-13 09:15:07 UTC
> 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
--
Comment 3 Petteri Räty (RETIRED) gentoo-dev 2007-03-13 09:29:08 UTC
(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.
Comment 4 Karl Schulz 2007-03-13 10:32:47 UTC
Created attachment 113153 [details, diff]
POSIX compliance for /etc/profile.d/java-config-2.sh
Comment 5 Karl Schulz 2007-03-13 10:34:45 UTC
> The best way to get this fixed is to submit a patch.

Ok, but I'm not a shell programmer...
Comment 6 Roy Marples (RETIRED) gentoo-dev 2007-03-16 07:28:21 UTC
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
Comment 7 Petteri Räty (RETIRED) gentoo-dev 2007-03-16 10:34:31 UTC
(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.
Comment 8 Petteri Räty (RETIRED) gentoo-dev 2007-03-16 10:45:46 UTC
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?
Comment 9 Roy Marples (RETIRED) gentoo-dev 2007-03-16 10:57:54 UTC
(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.
Comment 10 Petteri Räty (RETIRED) gentoo-dev 2007-03-16 11:12:20 UTC
Fixed in 2.0.31-r5. Thanks Karl, Uberlord and drizztbsd.