refactor(lua2dox_filter): format

This commit is contained in:
Lewis Russell
2022-10-10 12:21:40 +01:00
parent c401b06fe9
commit 3b6c7f9c7f

View File

@@ -22,20 +22,19 @@
LANG="" LANG=""
##! \brief test executable to see if it exists ##! \brief test executable to see if it exists
test_executable(){ test_executable() {
P_EXE="$1" P_EXE="$1"
######### #########
WHICH=`which ${P_EXE}` WHICH=$(which "$P_EXE")
if test -z "${WHICH}" if test -z "${WHICH}"; then
then
echo "not found \"${P_EXE}\"" echo "not found \"${P_EXE}\""
else else
EXE="${P_EXE}" EXE="${P_EXE}"
fi fi
} }
##! \brief sets the lua interpreter ##! \brief sets the lua interpreter
set_lua(){ set_lua() {
if test -z "${EXE}"; then if test -z "${EXE}"; then
test_executable '.deps/usr/bin/luajit' test_executable '.deps/usr/bin/luajit'
fi fi
@@ -53,34 +52,32 @@ set_lua(){
##! ##!
##! Note that "readlink -f" doesn't work in MacOSX ##! Note that "readlink -f" doesn't work in MacOSX
##! ##!
do_readlink(){ do_readlink() {
pushd . > /dev/null pushd . > /dev/null
TARGET_FILE=$1 TARGET_FILE=$1
cd `dirname $TARGET_FILE` cd "$(dirname $TARGET_FILE)"
TARGET_FILE=`basename $TARGET_FILE` TARGET_FILE=$(basename "$TARGET_FILE")
# Iterate down a (possible) chain of symlinks # Iterate down a (possible) chain of symlinks
while [ -L "$TARGET_FILE" ] while [ -L "$TARGET_FILE" ]; do
do TARGET_FILE=$(readlink "$TARGET_FILE")
TARGET_FILE=`readlink $TARGET_FILE` cd $(dirname "$TARGET_FILE")
cd `dirname $TARGET_FILE` TARGET_FILE=$(basename "$TARGET_FILE")
TARGET_FILE=`basename $TARGET_FILE`
done done
PHYS_DIR=`pwd -P` PHYS_DIR=$(pwd -P)
RESULT=$PHYS_DIR RESULT=$PHYS_DIR
popd > /dev/null popd > /dev/null
} }
##main ##main
set_lua set_lua
if test -z "${EXE}" if test -z "${EXE}"; then
then
echo "no lua interpreter found" echo "no lua interpreter found"
exit 1 exit 1
else else
BASENAME=`basename "$0"` BASENAME=$(basename "$0")
do_readlink "$0" do_readlink "$0"
DIRNAME="${RESULT}" DIRNAME="${RESULT}"
@@ -89,5 +86,5 @@ else
${EXE} ${LUASCRIPT} $@ ${EXE} ${LUASCRIPT} $@
fi fi
#
##eof ##eof