Update java stub template to check path components before qualifying
them with the pwd.
Fixes
Closes
@@ -288,28 +288,41 @@ ARGS=(
function create_and_run_classpath_jar() {
- # Build class path as one single string separated by spaces
- MANIFEST_CLASSPATH=""
+ # Build class path.
+ MANIFEST_CLASSPATH=()
if is_windows; then
CLASSPATH_SEPARATOR=";"
- URI_PREFIX="file:/" # e.g. "file:/C:/temp/foo.jar"
else
CLASSPATH_SEPARATOR=":"
- URI_PREFIX="file:$(pwd)/" # e.g. "file:/usr/local/foo.jar"
fi
- URI_PREFIX=${URI_PREFIX//\//\\/}
- MANIFEST_CLASSPATH="${CLASSPATH_SEPARATOR}${CLASSPATH}"
+ OLDIFS="$IFS"
+ IFS="${CLASSPATH_SEPARATOR}" # Use a custom separator for the loop.
+ for path in ${CLASSPATH}; do
+ # Convert spaces to %20
- MANIFEST_CLASSPATH=$(sed "s/ /%20/g" <<< "${MANIFEST_CLASSPATH}")
- MANIFEST_CLASSPATH=$(sed "s/$CLASSPATH_SEPARATOR/ $URI_PREFIX/g" <<< "${MANIFEST_CLASSPATH}")
+ if is_windows; then
+ path="file:/${path}" # e.g. "file:/C:/temp/foo.jar"
+ else
+ # If not absolute, qualify the path
+ case "${path}" in
+ /*) ;; # Already an absolute path
+ *) path="$(pwd)/${path}";; # Now qualified
+ esac
+ path="file:${path}" # e.g. "file:/usr/local/foo.jar"
+ fi
+
+ path=$(sed "s/ /%20/g" <<< "${path}")
+ MANIFEST_CLASSPATH+=("${path}")
+ done
+ IFS="$OLDIFS"
# Create manifest file
MANIFEST_FILE="$(mktemp -t XXXXXXXX.jar_manifest)"
(
echo "Manifest-Version: 1.0"
- CLASSPATH_LINE="Class-Path:$MANIFEST_CLASSPATH"
+ CLASSPATH_LINE="Class-Path: ${MANIFEST_CLASSPATH[*]}"
CLASSPATH_MANIFEST_LINES=$(sed -E $'s/(.{71})/\\1\\\n /g' <<< "${CLASSPATH_LINE}")
echo "$CLASSPATH_MANIFEST_LINES"
