create safeguard in test_writable
This prevents attempting to create files in `/` if a path is not given, instead failing early.
This commit is contained in:
parent
e011abae7b
commit
b0ab15c6da
|
|
@ -468,7 +468,11 @@ is_host_amd64_elf() {
|
||||||
# Test if a location is writeable by trying to write to it. Windows does not let
|
# 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
|
# you test writeability other than by writing: https://stackoverflow.com/q/1999988
|
||||||
test_writeable() {
|
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
|
if touch "${path}" 2>/dev/null; then
|
||||||
rm "${path}"
|
rm "${path}"
|
||||||
return 0
|
return 0
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue