Beware of bash 3.1

Matthias Saou thias at spam.spam.spam.spam.spam.spam.spam.egg.and.spam.freshrpms.net
Sat Apr 29 08:22:41 UTC 2006


Stephen John Smoogen wrote :

> On 4/28/06, Stephen John Smoogen <smooge at gmail.com> wrote:
> 
> > > cat <<EOF > /etc/profile.d/java.sh
> > > export JAVA_HOME=/opt/jre1.5.0_06
> > > export PATH=$JAVA_HOME/bin:$PATH
> > > EOF
> > >
> >
> >
> > In my bash addled brain.. I would say it is a bug. Expanding out data
> > that is being done in an EOF does not look in any way sh/ksh/etc
> > compliant.. and just prone to breaking too many things.
> >
> 
> Ok definately need sleep. It is doing what it is supposed to do in EOF
> sections. I am going to bed.. nevermind

Yeah, isn't the proper fix to simply single quote 'EOF'? Like this :

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

This should keep the $VARIABLES from being expanded in the resulting file.

Matthias

-- 
Clean custom Red Hat Linux rpm packages : http://freshrpms.net/
Fedora Core release 5.89 (Rawhide) - Linux kernel 2.6.16-1.2171_FC6
Load : 0.01 0.08 0.04




More information about the fedora-devel-list mailing list