From b0ab15c6da1a47bf279ffdd68c3949cc576ae52c Mon Sep 17 00:00:00 2001 From: aarondill Date: Wed, 5 Jul 2023 14:18:09 -0500 Subject: [PATCH] create safeguard in test_writable This prevents attempting to create files in `/` if a path is not given, instead failing early. --- install.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 2e832ad..df950ae 100755 --- a/install.sh +++ b/install.sh @@ -468,7 +468,11 @@ is_host_amd64_elf() { # Test if a location is writeable by trying to write to it. Windows does not let # you test writeability other than by writing: https://stackoverflow.com/q/1999988 test_writeable() { - path="${1:-}/test.txt" + if [ -z "${1-}" ]; then + # There's a bug if this is reached. + abort "BUG: test_writeable requires a path to test." + fi + path="$1/test.txt" if touch "${path}" 2>/dev/null; then rm "${path}" return 0