From dfd9d850f46a8e4abb3286bec3fc63b5b9576421 Mon Sep 17 00:00:00 2001 From: T3slider Date: Sun, 24 Jun 2018 22:14:19 -0400 Subject: [PATCH] Add support for mktemp If tempfile is not found, try mktemp; if neither is found, fall back to cat. --- ded/UrTUpdater_Ded.sh | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/ded/UrTUpdater_Ded.sh b/ded/UrTUpdater_Ded.sh index 6e60ca6..eb84b1e 100755 --- a/ded/UrTUpdater_Ded.sh +++ b/ded/UrTUpdater_Ded.sh @@ -237,17 +237,28 @@ function checkVersion () function doBrowser () { - TMPFILE=`tempfile -d "$CWD" -p tmp -s .html` - - echo "$1" > "$TMPFILE" + TMPFILE="" + if which tempfile >/dev/null 2>&1 ; then + TMPFILE=`tempfile -d "$CWD" -p tmp -s .html` + elif which mktemp >/dev/null 2>&1 ; then + TMPFILE=`mktemp -p "$CWD" tmpXXXXXX` + mv -f "$TMPFILE" "${TMPFILE}.html" + TMPFILE="${TMPFILE}.html" + fi - if [ -z "$BROWSER" ]; then - cat "$TMPFILE" + if [ -z "$TMPFILE" ]; then + echo "$1" else - $BROWSER "$TMPFILE" - fi + echo "$1" > "$TMPFILE" - rm -f "$TMPFILE" + if [ -z "$BROWSER" ]; then + cat "$TMPFILE" + else + $BROWSER "$TMPFILE" + fi + + rm -f "$TMPFILE" + fi } function drawLicence ()