1
0
mirror of synced 2026-01-12 00:42:56 +00:00
Interlisp.medley/run-medley
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

214 lines
5.5 KiB
Bash
Executable File

#!/bin/sh
# Run Medley
#
# Syntax: run-medley [-noscroll] #turn off scrollbars
# [--dimensions WIDTHxHEIGHT] # sets both -g -sc
# [-g WIDTHxHEIGHT]
# [-sc WIDTHxHEIGHT]
# [--display X_DISPLAY] # defaults to $DISPLAY or :0
# [-prog LDEFILE]
# [--vmem | --vmfile FILE]
# [--nogreet | --greet FILE |
# --loadup FILE ]
# [-n | -nl | -full | -lisp |
# [SYSOUTFILE]
# Variables accessible from Lisp via UNIX-GETENV
# LDESRCESYSOUT SYSOUT full-file name you want to run
# LDEDESTSYSOUT name for destination of SaveVM/LOGOUT
# MEDLEYDIR used by init file to set other path variables
#for x in "$@"; do echo $x; done
#exit
inferred_medleydir=false
if [ -z "$MEDLEYDIR" ] ; then
export MEDLEYDIR="$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )"
inferred_medleydir=true
fi
if [ ! -d "$MEDLEYDIR/loadups" ] ; then
echo "MEDLEYDIR has no loadups: $MEDLEYDIR"
if [ $inferred_medleydir = true ] ; then
echo "I tried to infer it based on your working directory, but that didn't work."
echo "Try cd there or setting the MEDLEYDIR environment variable to its location."
fi
exit 1
fi
# set defaults, overridden if suppplied explicitly
prog="lde"
pass=""
mem="-m 256"
scroll=22
noscroll=""
display=""
title="Medley Interlisp"
if [ -z "$LDEDESTSYSOUT" ] ; then
if [ -z "$LOGINDIR" ] ; then
export LDEDESTSYSOUT="${HOME}/lisp.virtualmem"
else
export LDEDESTSYSOUT="${LOGINDIR}/lisp.virtualmem"
fi
fi
if [ -z "$LDEINIT" ] ; then
export LDEINIT="$MEDLEYDIR/greetfiles/MEDLEYDIR-INIT"
fi
while [ "$#" -ne 0 ]; do
case "$1" in
-loadup)
# Keep (GREET) from finding a different init file
mkdir -p $MEDLEYDIR/tmp/logindir
export LOGINDIR=$MEDLEYDIR/tmp/logindir
export MEDLEYLOADUP="$2"
export LDEINIT="$2"
shift
;;
-nogreet | --nogreet)
# Keep (GREET) from finding an init file
mkdir -p $MEDLEYDIR/tmp/logindir
export LOGINDIR=$MEDLEYDIR/tmp/logindir
export LDEINIT="$MEDLEYDIR/greetfiles/NOGREET"
;;
-greet | --greet)
export LDEINIT="$2"
shift
;;
-noscroll)
scroll=0
noscroll="-noscroll"
;;
--dimensions | -dimensions)
sw=`expr "$2" : "\([0-9]*\)x[0-9]*$"`
sh=`expr "$2" : "[0-9]*x\([0-9]*\)$"`
if [ -n "$sw" -a -n "$sh" ] ; then
sw=$(( (31+$sw)/32*32 ))
gw=$(( $scroll+$sw ))
gh=$(( $scroll+$sh ))
geometry="-g ${gw}x${gh}"
screensize="-sc ${sw}x${sh}"
fi
shift
;;
--geometry | -geometry | -g)
geometry="-g $2"
shift
;;
--screensize | -screensize | -sc)
screensize="-sc $2"
shift
;;
--display | -d)
display="-display $2"
shift
;;
-prog)
prog="$2"
shift
;;
-m | -mem)
mem="-m $2 "
shift
;;
-title)
if [ -n "$2" ] ; then
title="$2"
fi
shift
;;
-vmem | --vmem | -vmfile)
export LDEDESTSYSOUT="$2"
shift
;;
-full)
export LDESRCESYSOUT="$MEDLEYDIR/loadups/full.sysout"
;;
-lisp)
export LDESRCESYSOUT="$MEDLEYDIR/loadups/lisp.sysout"
;;
-n | -new | -newfull)
export LDESRCESYSOUT="$MEDLEYDIR/tmp/full.sysout"
;;
-nl | -newlisp)
export LDESRCESYSOUT="$MEDLEYDIR/tmp/lisp.sysout"
;;
-NF)
pass="$pass $1" # for making init, don't fork
;;
-*)
pass="$pass $1 $2"
shift
;;
*)
echo sysout "$1"
export LDESRCESYSOUT="$1"
;;
esac
shift
done
if [ -z "$LDESRCESYSOUT" ] ; then
if [ -f "$LDEDESTSYSOUT" ] ; then
export LDESRCESYSOUT="$LDEDESTSYSOUT"
else
export LDESRCESYSOUT="$MEDLEYDIR/loadups/full.sysout"
fi
fi
if [ -z "$geometry" ] ; then
# maiko guesses wrong
geometry="-g 1440x900"
screensize="-sc 1440x900"
fi
if [ -z "${LDEKBDTYPE}" ]; then
export LDEKBDTYPE="X"
fi
if ! command -v "$prog" > /dev/null 2>&1; then
# if lde is already on path, don't reset it
# otherwise check for MAIKODIR
if [ -z "$MAIKODIR" ] ; then
# try two options relative to MEDLEYDIR: ./maiko and ../maiko
MAIKODIR="$MEDLEYDIR/../maiko"
if ! command -v "$MAIKODIR/bin/osversion" > /dev/null 2>&1; then
MAIKODIR="$MEDLEYDIR/maiko"
fi
fi
if ! command -v "$MAIKODIR/bin/osversion" > /dev/null 2>&1; then
echo "Could not find 'lde' on PATH"
echo "nor MAIKODIR with 'bin/osversion' (to look for it)"
exit 1
fi
oldpath="$PATH"
oldpwd=`pwd`
PATH=.:"$PATH"
cd "$MAIKODIR"/bin
osv=`osversion`
mct=`machinetype`
newpath="$MAIKODIR"/"$osv.$mct"
PATH="$newpath":"$oldpath"
cd "$oldpwd"
if ! command -v $prog > /dev/null 2>&1; then
echo $prog not found in $newpath
echo osversion = $osv
echo machinetype = $mct
exit 1
fi
fi
echo "running: $prog $display $noscroll $geometry $screensize -title \"$title\" $mem $pass $LDESRCESYSOUT"
echo "greet: $LDEINIT"
export INMEDLEY=1
"$prog" $display $noscroll $geometry $screensize $mem -title "$title" $pass "$LDESRCESYSOUT"