Skip to content

Commit 9c65965

Browse files
authored
Update jdk-wrapper to version 0.13.1 (#185)
1 parent 619eda0 commit 9c65965

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

.jdkw

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ JDKW_RELEASE=latest
22
JDKW_DIST=zulu
33
JDKW_BUILD=8.38.0.13
44
JDKW_VERSION=8.0.212
5-
JDKW_VERBOSE=true

jdk-wrapper.sh

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919

2020
log_err() {
2121
l_prefix=$(date +'%H:%M:%S')
22-
printf "[%s] %s\n" "${l_prefix}" "$@" 1>&2;
22+
printf "[%s] %s\\n" "${l_prefix}" "$@" 1>&2;
2323
}
2424

2525
log_out() {
2626
if [ -n "${JDKW_VERBOSE}" ]; then
2727
l_prefix=$(date +'%H:%M:%S')
28-
printf "[%s] %s\n" "${l_prefix}" "$@"
28+
printf "[%s] %s\\n" "${l_prefix}" "$@"
2929
fi
3030
}
3131

@@ -56,7 +56,7 @@ checksum() {
5656
log_err "ERROR: No supported checksum command found!"
5757
exit 1
5858
fi
59-
cat "${l_file}" | ${checksum_exec}
59+
"${checksum_exec}" < "${l_file}"
6060
}
6161

6262
rand() {
@@ -109,7 +109,7 @@ for arg in "$@"; do
109109
fi
110110
case "${arg}" in
111111
*\'*)
112-
arg=`printf "%s" "$arg" | sed "s/'/'\"'\"'/g"`
112+
arg=$(printf "%s" "$arg" | sed "s/'/'\"'\"'/g")
113113
;;
114114
*) : ;;
115115
esac
@@ -157,7 +157,7 @@ fi
157157
if [ "${JDKW_RELEASE}" = "latest" ]; then
158158
latest_version_json="${TMPDIR:-/tmp}/jdkw-latest-version-$$.$(rand)"
159159
safe_command "curl ${curl_options} -f -k -L -o \"${latest_version_json}\" -H 'Accept: application/json' \"${JDKW_BASE_URI}/releases/latest\""
160-
JDKW_RELEASE=$(cat "${latest_version_json}" | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
160+
JDKW_RELEASE=$(sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/' < "${latest_version_json}")
161161
rm -f "${latest_version_json}"
162162
log_out "Resolved latest version to ${JDKW_RELEASE}"
163163
fi
@@ -176,8 +176,24 @@ download_if_needed "${jdkw_impl}" "${jdkw_path}"
176176
download_if_needed "${jdkw_wrapper}" "${jdkw_path}"
177177

178178
# Execute the provided command
179-
eval ${jdkw_path}/${jdkw_impl} ${command}
180-
result=$?
179+
180+
# Run the command in the backround (with all the trouble that entails)
181+
# NOTE: Alternatively convert this to an exec if we don't need to output the
182+
# wrapper mismatch at the end; e.g. make that a hard precondition to running.
183+
trap 'kill -TERM ${impl_pid}' TERM INT
184+
"${jdkw_path}/${jdkw_impl}" "$@" &
185+
impl_pid=$!
186+
wait ${impl_pid} > /dev/null 2>&1
187+
wait_result=$?
188+
if [ ${wait_result} -ne 127 ]; then
189+
result=${wait_result}
190+
fi
191+
trap - TERM INT
192+
wait ${impl_pid} > /dev/null 2>&1
193+
wait_result=$?
194+
if [ ${wait_result} -ne 127 ]; then
195+
result=${wait_result}
196+
fi
181197

182198
# Check whether this wrapper is the one specified for this version
183199
jdkw_download="${jdkw_path}/${jdkw_wrapper}"

0 commit comments

Comments
 (0)