19
19
20
20
log_err () {
21
21
l_prefix=$( date +' %H:%M:%S' )
22
- printf " [%s] %s\n" " ${l_prefix} " " $@ " 1>&2 ;
22
+ printf " [%s] %s\\ n" " ${l_prefix} " " $@ " 1>&2 ;
23
23
}
24
24
25
25
log_out () {
26
26
if [ -n " ${JDKW_VERBOSE} " ]; then
27
27
l_prefix=$( date +' %H:%M:%S' )
28
- printf " [%s] %s\n" " ${l_prefix} " " $@ "
28
+ printf " [%s] %s\\ n" " ${l_prefix} " " $@ "
29
29
fi
30
30
}
31
31
@@ -56,7 +56,7 @@ checksum() {
56
56
log_err " ERROR: No supported checksum command found!"
57
57
exit 1
58
58
fi
59
- cat " ${l_file } " | ${checksum_exec}
59
+ " ${checksum_exec } " < " ${l_file} "
60
60
}
61
61
62
62
rand () {
@@ -109,7 +109,7 @@ for arg in "$@"; do
109
109
fi
110
110
case " ${arg} " in
111
111
* \' * )
112
- arg=` printf " %s" " $arg " | sed " s/'/'\" '\" '/g" `
112
+ arg=$( printf " %s" " $arg " | sed " s/'/'\" '\" '/g" )
113
113
;;
114
114
* ) : ;;
115
115
esac
157
157
if [ " ${JDKW_RELEASE} " = " latest" ]; then
158
158
latest_version_json=" ${TMPDIR:-/ tmp} /jdkw-latest-version-$$ .$( rand) "
159
159
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} " )
161
161
rm -f " ${latest_version_json} "
162
162
log_out " Resolved latest version to ${JDKW_RELEASE} "
163
163
fi
@@ -176,8 +176,24 @@ download_if_needed "${jdkw_impl}" "${jdkw_path}"
176
176
download_if_needed " ${jdkw_wrapper} " " ${jdkw_path} "
177
177
178
178
# 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
181
197
182
198
# Check whether this wrapper is the one specified for this version
183
199
jdkw_download=" ${jdkw_path} /${jdkw_wrapper} "
0 commit comments