From bc6e31d1c362a4be1c5eae8f90d000da28d2ff47 Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Mon, 23 Dec 2019 04:36:48 +0300 Subject: more robust cross platform temp directory detection --- peerflix-deadbeef | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/peerflix-deadbeef b/peerflix-deadbeef index 63901e7..26714b0 100755 --- a/peerflix-deadbeef +++ b/peerflix-deadbeef @@ -18,6 +18,12 @@ get_deadbeef() { fi } +tempdir() { + for TMPDIR in "$TMPDIR" "$TMP" /var/tmp /tmp; do + test -d "$TMPDIR" && echo "$TMPDIR" && break + done +} + download() { local source="$1" local target="$2" @@ -36,11 +42,11 @@ usage() { exit } -mktemp_m3u() { - mktemp $TMPDIR/$(uuidgen).m3u +tempname() { + echo $(tempdir)/$(uuidgen).m3u } -VERSION="0.2" +VERSION="0.3" NAME="peerflix-deadbeef" DEADBEEF="$(get_deadbeef)" @@ -53,7 +59,7 @@ installed curl || installed wget || error "curl or wget is required" if [[ "$1" == "--ready" ]]; then host="$2" port="$3" - file=$(mktemp_m3u) + file=$(tempname) url="http://$host:$port/.m3u" usleep 100000 -- cgit v1.2.3