Skip to content
This repository was archived by the owner on Jan 20, 2024. It is now read-only.

Commit c044ace

Browse files
committed
installer.sh: fix crash if ARCHIVE_PATH is empty
1 parent fe7ba0d commit c044ace

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

installer.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,31 +37,34 @@ fi
3737
BIN_PATH="${HOME}/.local/bin"
3838
APP_PATH="${HOME}/.local/share/applications"
3939
SYS_PATH="${HOME}/.local/share/loffice-365"
40-
if [ -n "$1" ]; then
40+
if [ -f "$1" ]; then
4141
ARCHIVE_PATH=$(readlink -f "$1")
4242
fi
43-
DEFAULT_ARCHIVE_PATH=$(readlink -f "binaries/loffice-365.tgz")
43+
if [ -f "binaries/loffice-365.tgz" ]; then
44+
DEFAULT_ARCHIVE_PATH=$(readlink -f "binaries/loffice-365.tgz")
45+
fi
4446

4547
# Download app
4648
rm -rf "${SYS_PATH}"
4749
mkdir -p "${HOME}/.local/share/"
4850
mkdir -p "${BIN_PATH}"
4951
mkdir -p "${APP_PATH}"
5052
cd "${HOME}/.local/share/"
51-
if [ -n "$1" ]; then
53+
if [ -n "${ARCHIVE_PATH}" ] && [ -f ${ARCHIVE_PATH} ]; then
5254
# Use specified local loffice-365.tgz
53-
echo "Using ${ARCHIVE_PATH}"
55+
echo "Using specified archive at ${ARCHIVE_PATH}"
5456
mkdir loffice-365
5557
tar xfz ${ARCHIVE_PATH} -C loffice-365 --strip-components=1
56-
elif [ -f ${DEFAULT_ARCHIVE_PATH} ]; then
58+
elif [ -n "${DEFAULT_ARCHIVE_PATH}" ] && [ -f ${DEFAULT_ARCHIVE_PATH} ]; then
5759
# Use default location of built loffice-365.tgz
58-
echo "Using ${DEFAULT_ARCHIVE_PATH}"
60+
echo "Using archive at ${DEFAULT_ARCHIVE_PATH}"
5961
mkdir loffice-365
6062
tar xfz ${DEFAULT_ARCHIVE_PATH} -C loffice-365 --strip-components=1
6163
else
6264
# Download latest release from adil192/loffice-365
63-
echo "Downloading latest release from adil192/loffice-365"
65+
echo "Using latest release from adil192/loffice-365"
6466
ARCHIVE=$(curl https://api.github.com/repos/adil192/loffice-365/releases |grep browser_download_url |head -n1 |sed 's/"browser_download_url": "//g;s/"//g;s/ //g')
67+
echo "Downloading ${ARCHIVE}"
6568
curl -L "${ARCHIVE}" --output loffice-365.tgz
6669
tar xfz loffice-365.tgz
6770
rm -f loffice-365.tgz

0 commit comments

Comments
 (0)