0

After installing JAVA(JDK) whenever I reboot the system or switch to normal user a message is displayed:

bash: ${AUTO_CLASSPATH_DIR}: invalid variable name

bash: ${AUTO_CLASSPATH_DIR}: invalid variable name

This is the configuration script

cat > /etc/profile.d/openjdk.sh << "EOF"
# Begin /etc/profile.d/openjdk.sh

# Set JAVA_HOME directory
JAVA_HOME=/opt/jdk

# Adjust PATH
pathappend $JAVA_HOME/bin

# Add to MANPATH
pathappend $JAVA_HOME/man MANPATH

# Auto Java CLASSPATH: Copy jar files to, or create symlinks in, the
# /usr/share/java directory. Note that having gcj jars with OpenJDK 8
# may lead to errors.

AUTO_CLASSPATH_DIR=/usr/share/java

pathprepend . CLASSPATH

for dir in `find ${AUTO_CLASSPATH_DIR} -type d 2>/dev/null`; do
    pathappend $dir CLASSPATH
done

for jar in `find ${AUTO_CLASSPATH_DIR} -name "*.jar" 2>/dev/null`; do
    pathappend $jar CLASSPATH
done

export JAVA_HOME
unset AUTO_CLASSPATH_DIR dir jar

# End /etc/profile.d/openjdk.sh
EOF

This is the output of bash -xv /etc/profile.d/openjdk.sh

pathappend () { pathremove $1 $2;
local PATHVARIABLE=${2:-PATH};
export $PATHVARIABLE="${!PATHVARIABLE:+${!PATHVARIABLE}:}$1"
}
pathprepend () { pathremove $1 $2;
local PATHVARIABLE=${2:-PATH};
export $PATHVARIABLE="$1${!PATHVARIABLE:+:${!PATHVARIABLE}}"
}
pathremove () { local IFS=':';
local NEWPATH;
local DIR;
local PATHVARIABLE=${2:-PATH};
for DIR in ${!PATHVARIABLE};
do
if [ "$DIR" != "$1" ]; then
NEWPATH=${NEWPATH:+$NEWPATH:}$DIR;
fi;
done;
export $PATHVARIABLE="$NEWPATH"
}
# Begin /etc/profile.d/openjdk.sh

# Set JAVA_HOME directory
JAVA_HOME=/opt/jdk
+ JAVA_HOME=/opt/jdk

# Adjust PATH
pathappend $JAVA_HOME/bin
+ pathappend /opt/jdk/bin
+ pathremove /opt/jdk/bin
+ local IFS=:
+ local NEWPATH
+ local DIR
+ local PATHVARIABLE=PATH
+ for DIR in ${!PATHVARIABLE}
+ '[' /bin '!=' /opt/jdk/bin ']'
+ NEWPATH=/bin
+ for DIR in ${!PATHVARIABLE}
+ '[' /usr/bin '!=' /opt/jdk/bin ']'
+ NEWPATH=/bin:/usr/bin
+ for DIR in ${!PATHVARIABLE}
+ '[' /opt/jdk/bin '!=' /opt/jdk/bin ']'
+ export PATH=/bin:/usr/bin
+ PATH=/bin:/usr/bin
+ local PATHVARIABLE=PATH
+ export PATH=/bin:/usr/bin:/opt/jdk/bin
+ PATH=/bin:/usr/bin:/opt/jdk/bin

# Add to MANPATH
pathappend $JAVA_HOME/man MANPATH
+ pathappend /opt/jdk/man MANPATH
+ pathremove /opt/jdk/man MANPATH
+ local IFS=:
+ local NEWPATH
+ local DIR
+ local PATHVARIABLE=MANPATH
+ for DIR in ${!PATHVARIABLE}
+ '[' /usr/share/man '!=' /opt/jdk/man ']'
+ NEWPATH=/usr/share/man
+ for DIR in ${!PATHVARIABLE}
+ '[' opt/jdk/man '!=' /opt/jdk/man ']'
+ export MANPATH=/usr/share/man
+ MANPATH=/usr/share/man
+ local PATHVARIABLE=MANPATH
+ export MANPATH=/usr/share/man:/opt/jdk/man
+ MANPATH=/usr/share/man:/opt/jdk/man

# Auto Java CLASSPATH: Copy jar files to, or create symlinks in, the
# /usr/share/java directory. Note that having gcj jars with OpenJDK 8
# may lead to errors.

AUTO_CLASSPATH_DIR=/usr/share/java
+ AUTO_CLASSPATH_DIR=/usr/share/java

pathprepend . CLASSPATH
+ pathprepend . CLASSPATH
+ pathremove . CLASSPATH
+ local IFS=:
+ local NEWPATH
+ local DIR
+ local PATHVARIABLE=CLASSPATH
+ for DIR in ${!PATHVARIABLE}
+ '[' . '!=' . ']'
+ export CLASSPATH=
+ CLASSPATH=
+ local PATHVARIABLE=CLASSPATH
+ export CLASSPATH=.
+ CLASSPATH=.


for dir in `find ${AUTO_CLASSPATH_DIR} -type d 2>/dev/null`; do
pathappend $dir CLASSPATH
done
+ for dir in `find ${AUTO_CLASSPATH_DIR} -type d 2>/dev/null`
+ pathappend find '${AUTO_CLASSPATH_DIR}' -type d '2>/dev/null` CLASSPATH
+ pathremove find '${AUTO_CLASSPATH_DIR}'
+ local IFS=:
+ local NEWPATH
+ local DIR
+ local 'PATHVARIABLE=${AUTO_CLASSPATH_DIR}'
environment: line 4: ${AUTO_CLASSPATH_DIR}: invalid variable name

for jar in `find ${AUTO_CLASSPATH_DIR} -name "*.jar" 2>/dev/null`; do
pathappend $jar CLASSPATH
done
+ for jar in `find ${AUTO_CLASSPATH_DIR} -name "*.jar" 2>/dev/null`
+ pathappend find '${AUTO_CLASSPATH_DIR}' -name '"*.jar"' '2>/dev/null` CLASSPATH
+ pathremove find '${AUTO_CLASSPATH_DIR}'
+ local IFS=:
+ local NEWPATH
+ local DIR
+ local 'PATHVARIABLE=${AUTO_CLASSPATH_DIR}'
environment: line 4: ${AUTO_CLASSPATH_DIR}: invalid variable name

export JAVA_HOME
+ export JAVA_HOME
unset AUTO_CLASSPATH_DIR dir jar
+ unset AUTO_CLASSPATH_DIR dir jar

# End /etc/profile.d/openjdk.sh

In the output file also it's written invalid variable name for AUTO_CLASSPATH_DIR

I'm using bash 5.0 ( BLFS 8.4 environment )

7
  • I'm trying to install BLFS 8.4 – Palash Tekam Oct 27 '20 at 11:36
  • @steeldriver how do I change it? Is there any thing that I change in the configuration script? The script is from the BLFS book how could it be wrong? – Palash Tekam Oct 27 '20 at 14:09
  • I'm using an old laptop, if it does make a difference for BLFS 8.4 – Palash Tekam Oct 27 '20 at 14:16
  • Is there any way to make changes in bash -xv /etc/profile.d/openjdk.sh? Will it do anything? – Palash Tekam Oct 27 '20 at 14:17
  • @steeldriver In the script there is AUTO_CLASSPATH_DIR=/usr/share/java but no such directory is created, I also tried to create the directory manual beforehand but, the problem still persists. – Palash Tekam Oct 27 '20 at 14:35
0

The problem was that I couldn't differentiate between a backtick and a single quote (because am doing this on an old laptop, I have to type in everything). I wrote the script again after this and it ran fine.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.