From 1d875d3abb95ab8b30d37df2204f7dc7f4e6dd4d Mon Sep 17 00:00:00 2001 From: aarondill Date: Tue, 23 Jan 2024 03:35:50 -0600 Subject: [PATCH] fix: test_writable should fail for empty paths This prevents attempting to create files in `/` if a path is not given, instead failing early. --- install.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 1ad4275..6d0ed85 100755 --- a/install.sh +++ b/install.sh @@ -466,7 +466,10 @@ elevate_priv() { # 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 + return 1 # an empty path should never be writeable + fi + path="$1/test.txt" if touch "${path}" 2>/dev/null; then rm "${path}" return 0