#1164 closed defect (fixed)
auto-java-classpath functionality breaks on spaces in file names
Reported by: | Nico R. | Owned by: | |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | BOOK | Version: | SVN |
Severity: | normal | Keywords: | |
Cc: |
Description
The auto-java-classpath script snippet does not work correctly if any of the path components contains spaces.
Example: /usr/lib/auto-java-classpath/foobar.jar /usr/lib/auto-java-classpath/foo bar.jar
Result: CLASSPATH=".:/usr/lib/auto-java-classpath:/usr/lib/auto-java-classpath/foo:bar.jar:/usr/lib/auto-java-classpath/foobar.jar"
Expected result: CLASSPATH=".:/usr/lib/auto-java-classpath:/usr/lib/auto-java-classpath/foo bar.jar:/usr/lib/auto-java-classpath/foobar.jar"
Suggestion to fix this: Replace with the following lines:
AUTO_CLASSPATH_DIR='/usr/lib/auto-java-classpath' CLASSPATH="${CLASSPATH}${CLASSPATH:+:}.:${AUTO_CLASSPATH_DIR}" ls "${AUTO_CLASSPATH_DIR}"/*.jar &>/dev/null && for f in "${AUTO_CLASSPATH_DIR}"/*.jar; do
CLASSPATH="${CLASSPATH}:${f}"
done export CLASSPATH
This will still catch the case of the auto-java-classpath directory being empty, but it will also work if it contains files with spaces in their filenames. It might need a little longer to execute, though.
Fixed in previous update to use profile.d directory.