Beware of bash 3.1

Callum Lerwick seg at haxxed.com
Sat Apr 29 03:25:01 UTC 2006


Okay, I originally posted about this a few months ago:

http://www.redhat.com/archives/rhl-devel-list/2006-January/msg00491.html

A seemingly harmless corner case. Here's another one:

<BobJensen> one of my guys ran a java install script as sudo and fubar'd
the box
<BobJensen> he was following these instructions
http://fedorasolved.org/browser-solutions/java-i386/

Step 9, which looks like this:

cat <<EOF > /etc/profile.d/java.sh
export JAVA_HOME=/opt/jre1.5.0_06
export PATH=$JAVA_HOME/bin:$PATH
EOF

Results in this:

# cat /etc/profile.d/java.sh
export JAVA_HOME=/opt/jre1.5.0_06
export PATH=/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/lib64/ccache:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin

Which is wrong. The fix is of course:

# cat <<EOF > ~/java.sh
> export JAVA_HOME=/opt/jre1.5.0_06
> export PATH=\$JAVA_HOME/bin:\$PATH
> EOF

# cat ~/java.sh
export JAVA_HOME=/opt/jre1.5.0_06
export PATH=$JAVA_HOME/bin:$PATH

So... bash 3.1 has definitely changed the way variable expansion is
done, namely it expands things it didn't used to expand. Bug or feature?
Either way, beware.

(And there's the larger issue, being that those instructions suck,
instead you should be using http://www.city-fan.org/tips/JpackageJava
which is linked from http://www.fedoraproject.org/wiki/JavaFAQ and thus
appears to be officially blessed. But that's not really an issue for
-devel...)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://listman.redhat.com/archives/fedora-devel-list/attachments/20060428/46399f2a/attachment.sig>


More information about the fedora-devel-list mailing list