Gitlab was updated! v14.5.1

Verified Commit 70654b0c authored by Simão Afonso @ Powertools Tech's avatar Simão Afonso @ Powertools Tech
Browse files

Support a getopts interface

No more running `virtualatex -h` and getting an error.
parent aa52c2fc
......@@ -9,7 +9,7 @@ TexLive_Repo=${CTAN_REPO:-http://mirror.ctan.org/systems/texlive/tlnet}
TexLive_File="install-tl-unx.tar.gz"
TexLive_URL="$TexLive_Repo/$TexLive_File"
setup_tinytex() { # Install Location
setup_tinytex() { # InstallLocation Force?
il="$(readlink -e "$1")"
tmp="$(mktemp -d)" # Temporary Location
pushd "$tmp" 2>/dev/null
......@@ -35,13 +35,14 @@ setup_tinytex() { # Install Location
echo "- TexLive: $il_texlive"
echo "=> Platform (Script): $platform"
# TODO: Gate this to a `-f` flag
# Do it!
# if [ -d "$il_texlive" ]; then
# # TODO: I *think* TeXlive supports overwiting...
# echo "=> Re-Installing TexLive"
# rm -rf "$il_texlive"
# fi
if [ "${2:-no}" == yes ]; then
# Do it!
if [ -d "$il_texlive" ]; then
# TeXlive supports overwriting, but this a clean slate
echo "=> Re-Installing TexLive"
rm -rf "$il_texlive"
fi
fi
echo "=> Installing TexLive @ '$il_texlive'"
# Ripped off from TinyTex: https://github.com/yihui/tinytex/blob/master/tools/tinytex.profile
cat >"$tmp/tinytex.profile" <<-TINYTEX
......@@ -88,16 +89,50 @@ setup_tinytex() { # Install Location
rm -rf "$tmp"
}
install_location="${1:-"$PWD"}"
install_location="$PWD"
overwrite=no
force=no
while getopts ':hofv' opt; do
case "$opt" in
o) overwrite=yes ;;
f)
force=yes
overwrite=yes
;;
v)
echo "$VIRTUALTEX_VERSION"
exit 0
;;
h|*)
cat <<-USAGE
Usage: $0 [-h] [-of] [INSTALL_LOCATION]
|-o: Overwrite existing location
|-f: Force installation (remove old installation first)
|-v: Show virtualatex version
INSTALL_LOCATION is the root location.
Defaults to '$install_location'
USAGE
exit 1
;;
esac
done
shift $((OPTIND - 1))
install_location="${1:-$install_location}"
if [ -e "$install_location" ]; then
if test -d "$install_location"; then
echo "Existing Location: $install_location" >&2
exit 1
if [ "$overwrite" == "no" ]; then
exit 1
fi
else
echo "Invalid Location: $install_location" >&2
exit 2
fi
else
fi
if [ ! -d "$install_location" ]; then
# Create only a single directory level, if needed
mkdir "$install_location"
setup_tinytex "$install_location"
fi
setup_tinytex "$install_location" "$force"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment