1
0
mirror of synced 2026-01-22 10:50:53 +00:00
Interlisp.medley/scripts/medley/medley_configfile.sh
Frank Halasz 415a698df5
Overhaul of loadup scripts (#1699)
* Make medley.sh and its associated scripts POSIX compliant - i.e., debashify them

* Added config file for medley script, medley now reads from config file and prepends arguemnts from file to the copmmand line arguments

* WIP. Updates to medley.sh scripts.

* WIP.  More on medley.sh and friends update.

* WIP. Medley redo

* WIP.  Debugging new medley scripts

* Renamed medley.sh/medley.command to be medley_main.sh.  Added code to compile single medley.sh/medley.command script by inlining all of the source'd medley_*.sh files.

* Add temp fix for cygwin Issue #1685

* Minor fixup to medley_utils.sh; take debug code out out of run_medley

* Add README to medley directory to explain how to compile medley.sh (medley.command).

* Ooops. This time really adding the README file to the medley directory explaining how to compile medley.sh (medley.command)

* Update loadup- scripts to use updated medley scripts rather than run-medley

* Fix default setting of $config_file in medley_configfile.sh

* Redo medley compile to pick up last commikt

* Fixing how maiko exe is found and sysout argument error processing - both issues discovered testing on MAcOS

* In medley_configfile, replace echo with printf %s because echo - does not work in zsh

* Supress config file on loadups calls to Medley

* Add oldschool support (use original run-medley) to loadup scripts; improve FAILURE detection so loadup-all won't proceed once one of the components fails

* Add in medley_args.sh add -prog as synonym to --maikoprog to aid in loadup scripts; in medley_run.sh script try to get a good exit code for call to maiko, especially useful for loadup scripts

* Run loadup scripts thru shellcheck and update as necessary to make Posix compliant

* Get rid of -nt comparisons in loadup-setup.sh because they are not posix-complaint.  They were not really needed anyway.

* Removing (for now) use of lde exit codes to decide FAILURE case in loadup-setup.sh since exit codes from lde apperar to be inverted on MacOS.

* Update medley man page.  Add - functionality to more args is medley_args.sh

* Compile medley.sh with changes from last commit

* Ooops.  Left medley_args.sh changes out of last commit.  Rectifying here.

* Added support for LDEKEYBOARDTYPE to medley_run to match run-medley

* Add to medley.sh: auto numbered id's and titles with id's inserted

* Cleanup some shellcheck issues in medley_main.sh

* fix maiko args -nh-xxx.  were -nethub-xxxx. In medley_run.sh

* Overhaul handling of pass-on args to manage the quoting issues prevelant in the previous implementation

* Cleanup minor shellcheck issues in medley_*.sh scripts

* Add underscore as character allowed in ids - makes things clearer when id used with +

* Add a self-numbering id to medley calls in loadup scripts

* Put workaround in medley_run.sh for Issue #1702 - issues with sysout arg processing in Maiko

* Oops.  messed up LDESRCSYSOUT in last commit.  should be LDESOURCESYSOUT

* compile medley.sh
2024-05-09 21:31:27 -07:00

79 lines
2.0 KiB
Bash

#!only-to-be-sourced
# shellcheck shell=sh
###############################################################################
#
# medley_configfile.sh - script for processing the config file for the
# medley.sh script.
#
# !!!! This script is meant to be SOURCEd from the scripts/medley.sh script.
# !!!! It should not be run as a standlone script.
#
# 2024-04-20 Frank Halasz
#
# Copyright 2024 Interlisp.org
#
###############################################################################
config_file=""
# look thru args looking to see if a config file was specified
j=1
jmax=$#
while [ "$j" -le "$jmax" ]
do
if [ "$(eval "printf %s \${${j}}")" = "-c" ] || [ "$(eval "printf %s \${${j}}")" = "--config" ]
then
k=$(( j + 1 ))
config_file="$(eval "printf %s \${${k}}")"
if [ ! "${config_file}" = "-" ] && [ ! -f "${config_file}" ]
then
echo "Error: specified config file \"${config_file}\" not found."
echo "Exiting."
exit 52
fi
j=$(( j + 1 ))
fi
j=$(( j + 1 ))
done
# if no config file specified, use the defaults (if they exist)
if [ -z "${config_file}" ]
then
for f in "${HOME}/.medley_config" "${MEDLEYDIR}/.medley_config"
do
if [ -f "$f" ]
then
config_file="$f"
fi
done
fi
# add marker to separate config file args from command line args
set -- "--start_cl_args" "--start_cl_args" "$@"
# if there is a config file and its not been suppressed with "-",
# read the config file (in reverse order) and add the first two items on each line
# to the arguments array
if [ -n "${config_file}" ] && [ ! "${config_file}" = "-" ]
then
rev_config_file="${TMPDIR:-/tmp}"/.medley_config_$$
# reverse order of lines in medley config file
sed '1!x;H;1h;$!d;g' < "${config_file}" >"${rev_config_file}"
while read -r arg1 arg2
do
if [ -n "${arg2}" ]
then
arg2="$(echo "${arg2}" | sed s/\"//g)"
set -- "${arg2}" "$@"
fi
if [ -n "${arg1}" ]
then
set -- "${arg1}" "$@"
fi
done < "${rev_config_file}"
rm -f "${rev_config_file}"
fi