Skip to content

Commit f53da75

Browse files
authored
Fix Issue #1848: Medley script (and hence loadup script) now checks for lde (ldeinit) on PATH (#2129)
In medley script(s), when executing maiko (lde or ldeinit) check if its on the PATH before looking for it in MEDLEYDIR/maiko or MEDLEYDIR/../maiko.
1 parent 39ebd40 commit f53da75

File tree

3 files changed

+58
-36
lines changed

3 files changed

+58
-36
lines changed

scripts/medley/medley.command

+29-18
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,7 @@ do
931931
;;
932932
--maikodir)
933933
# for use in loadups
934-
if [ "$2" = "-" ] || [ "$2" == "--" ]
934+
if [ "$2" = "-" ] || [ "$2" = "--" ]
935935
then
936936
maikodir_arg=""
937937
maikodir_stage=""
@@ -1360,34 +1360,45 @@ check_for_maiko_exe () {
13601360
13611361
if [ -z "${maikodir_arg}" ]
13621362
then
1363-
if check_for_maiko_exe "${MEDLEYDIR}/maiko"
1364-
then
1365-
maikodir_arg="${MEDLEYDIR}/maiko"
1366-
elif check_for_maiko_exe "${MEDLEYDIR}/../maiko"
1363+
# No MAIKODIR specified. But is lde (or ldeinit) on the PATH?
1364+
# If so, use it.
1365+
maiko_exe="$(command -v "${maikoprog_arg}")"
1366+
if [ -z "${maiko_exe}" ]
13671367
then
1368-
maikodir_arg="$(cd "${MEDLEYDIR}/../maiko"; pwd)"
1369-
else
1370-
if ! check_if_maiko_dir "${MEDLEYDIR}/maiko" && ! check_if_maiko_dir "${MEDLEYDIR}/../maiko"
1368+
# Lde (or ledinit) is not on the PATH, check in MEDLEYDIR/maiko and in MEDLEYDIR/../maiko
1369+
if check_for_maiko_exe "${MEDLEYDIR}/maiko"
13711370
then
1372-
err_msg="ERROR: Cannot find the Maiko directory at either
1373-
\"${MEDLEYDIR}/maiko\" or \"${MEDLEYDIR}/../maiko\".
1371+
maikodir_arg="${MEDLEYDIR}/maiko"
1372+
elif check_for_maiko_exe "${MEDLEYDIR}/../maiko"
1373+
then
1374+
maikodir_arg="$(cd "${MEDLEYDIR}/../maiko"; pwd)"
1375+
else
1376+
# Not in MEDLEYDIR/maiko and in MEDLEYDIR/../maiko, put out the appropriate error msg and exit
1377+
if ! check_if_maiko_dir "${MEDLEYDIR}/maiko" && ! check_if_maiko_dir "${MEDLEYDIR}/../maiko"
1378+
then
1379+
err_msg="ERROR: The maiko executable ($maikoprog_arg) is not on the PATH and cannot find
1380+
the Maiko directory at either \"${MEDLEYDIR}/maiko\"
1381+
or \"${MEDLEYDIR}/../maiko\".
13741382
You can use the --maikodir argument or the MAIKODIR env variable
13751383
to specify the Maiko directory.
13761384
Exiting."
1377-
output_error_msg "${err_msg}"
1378-
exit 53
1379-
else
1380-
err_msg="ERROR: Cannot find the Maiko executable (${maiko_exe_subdir}/${maikoprog_arg}) in either
1381-
\"${MEDLEYDIR}/maiko\" or \"${MEDLEYDIR}/../maiko\".
1385+
output_error_msg "${err_msg}"
1386+
exit 53
1387+
else
1388+
err_msg="ERROR: The maiko executable ($maikoprog_arg) is not on the PATH and cannot find
1389+
the Maiko executable (${maiko_exe_subdir}/${maikoprog_arg}) in either \"${MEDLEYDIR}/maiko\"
1390+
or \"${MEDLEYDIR}/../maiko\".
13821391
Exiting."
1383-
output_error_msg "${err_msg}"
1384-
exit 54
1392+
output_error_msg "${err_msg}"
1393+
exit 54
1394+
fi
13851395
fi
13861396
fi
13871397
elif ! check_if_maiko_dir "${maikodir_arg}" || ! check_for_maiko_exe "${maikodir_arg}"
13881398
then
1399+
# MAIKODIR is specified but lde (or ldeinit) is not in fact there. Error exit.
13891400
err_msg="In ${maikodir_stage}:
1390-
ERROR: The value provided by \$MAIKODIR or by the --maikodir argument ("${maikodir_arg}") is not
1401+
ERROR: The value provided by \$MAIKODIR or by the --maikodir argument (${maikodir_arg}) is not
13911402
in fact a directory containing the Maiko emulator (${maiko_exe_subdir}/${maikoprog_arg}).
13921403
Exiting."
13931404
output_error_msg "${err_msg}"

scripts/medley/medley_args.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ do
341341
;;
342342
--maikodir)
343343
# for use in loadups
344-
if [ "$2" = "-" ] || [ "$2" == "--" ]
344+
if [ "$2" = "-" ] || [ "$2" = "--" ]
345345
then
346346
maikodir_arg=""
347347
maikodir_stage=""

scripts/medley/medley_run.sh

+28-17
Original file line numberDiff line numberDiff line change
@@ -235,34 +235,45 @@ check_for_maiko_exe () {
235235

236236
if [ -z "${maikodir_arg}" ]
237237
then
238-
if check_for_maiko_exe "${MEDLEYDIR}/maiko"
238+
# No MAIKODIR specified. But is lde (or ldeinit) on the PATH?
239+
# If so, use it.
240+
maiko_exe="$(command -v "${maikoprog_arg}")"
241+
if [ -z "${maiko_exe}" ]
239242
then
240-
maikodir_arg="${MEDLEYDIR}/maiko"
241-
elif check_for_maiko_exe "${MEDLEYDIR}/../maiko"
242-
then
243-
maikodir_arg="$(cd "${MEDLEYDIR}/../maiko"; pwd)"
244-
else
245-
if ! check_if_maiko_dir "${MEDLEYDIR}/maiko" && ! check_if_maiko_dir "${MEDLEYDIR}/../maiko"
243+
# Lde (or ledinit) is not on the PATH, check in MEDLEYDIR/maiko and in MEDLEYDIR/../maiko
244+
if check_for_maiko_exe "${MEDLEYDIR}/maiko"
245+
then
246+
maikodir_arg="${MEDLEYDIR}/maiko"
247+
elif check_for_maiko_exe "${MEDLEYDIR}/../maiko"
246248
then
247-
err_msg="ERROR: Cannot find the Maiko directory at either
248-
\"${MEDLEYDIR}/maiko\" or \"${MEDLEYDIR}/../maiko\".
249+
maikodir_arg="$(cd "${MEDLEYDIR}/../maiko"; pwd)"
250+
else
251+
# Not in MEDLEYDIR/maiko and in MEDLEYDIR/../maiko, put out the appropriate error msg and exit
252+
if ! check_if_maiko_dir "${MEDLEYDIR}/maiko" && ! check_if_maiko_dir "${MEDLEYDIR}/../maiko"
253+
then
254+
err_msg="ERROR: The maiko executable ($maikoprog_arg) is not on the PATH and cannot find
255+
the Maiko directory at either \"${MEDLEYDIR}/maiko\"
256+
or \"${MEDLEYDIR}/../maiko\".
249257
You can use the --maikodir argument or the MAIKODIR env variable
250258
to specify the Maiko directory.
251259
Exiting."
252-
output_error_msg "${err_msg}"
253-
exit 53
254-
else
255-
err_msg="ERROR: Cannot find the Maiko executable (${maiko_exe_subdir}/${maikoprog_arg}) in either
256-
\"${MEDLEYDIR}/maiko\" or \"${MEDLEYDIR}/../maiko\".
260+
output_error_msg "${err_msg}"
261+
exit 53
262+
else
263+
err_msg="ERROR: The maiko executable ($maikoprog_arg) is not on the PATH and cannot find
264+
the Maiko executable (${maiko_exe_subdir}/${maikoprog_arg}) in either \"${MEDLEYDIR}/maiko\"
265+
or \"${MEDLEYDIR}/../maiko\".
257266
Exiting."
258-
output_error_msg "${err_msg}"
259-
exit 54
267+
output_error_msg "${err_msg}"
268+
exit 54
269+
fi
260270
fi
261271
fi
262272
elif ! check_if_maiko_dir "${maikodir_arg}" || ! check_for_maiko_exe "${maikodir_arg}"
263273
then
274+
# MAIKODIR is specified but lde (or ldeinit) is not in fact there. Error exit.
264275
err_msg="In ${maikodir_stage}:
265-
ERROR: The value provided by \$MAIKODIR or by the --maikodir argument ("${maikodir_arg}") is not
276+
ERROR: The value provided by \$MAIKODIR or by the --maikodir argument (${maikodir_arg}) is not
266277
in fact a directory containing the Maiko emulator (${maiko_exe_subdir}/${maikoprog_arg}).
267278
Exiting."
268279
output_error_msg "${err_msg}"

0 commit comments

Comments
 (0)