commit 27f6d7c91614270413ba99f3f6bded539d4b6b40
parent 63a4e15dd6d39dece98e00b04719c701907d56e1
Author: René Wagner <rwa@clttr.info>
Date: Mon, 31 Jul 2023 20:39:41 +0200
use per-instance temp-files for curpage, history and links
When using multiple astro instances at once, they will
interfere with each other due to using the same temp files.
We avoid this by creating individual temp files per
instance via 'mktemp'
Diffstat:
M | astro | | | 15 | ++++++++------- |
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/astro b/astro
@@ -117,8 +117,9 @@ fi
. "$configfile"
mkdir -p "$cachedir"
-histfile="$cachedir/history"
-linksfile="$cachedir/links"
+pagefile="$(mktemp -p "$cachedir" -t curpage.XXXXXX)"
+histfile="$(mktemp -p "$cachedir" -t history.XXXXXX)"
+linksfile="$(mktemp -p "$cachedir" -t links.XXXXXX)"
# Restore terminal
trap 'tput rmcup && rm -f $histfile $linksfile > /dev/null 2>&1; exit' EXIT INT HUP
@@ -277,13 +278,13 @@ EOF
echo "$1://$2:$3/$4$5" | eval openssl s_client \
-connect "$2:$3" "$certfile" -crlf -quiet \
- -ign_eof 2> /dev/null > "$cachedir/curpage"
+ -ign_eof 2> /dev/null > "$pagefile"
# First line is status and meta information
- read -r status meta < "$cachedir/curpage"
+ read -r status meta < "$pagefile"
status="$(echo "$status" | tr -d '\r\n')"
meta="$(echo "$meta" | tr -d '\r\n')"
- sed -i '1d' "$cachedir/curpage"
+ sed -i '1d' "$pagefile"
debug "response header: $status $meta"
# Validate
@@ -387,9 +388,9 @@ EOF
*".gmi"|"") typesetgmi ;;
*.*) cat ;;
*) typesetgmi ;;
- esac < "$cachedir/curpage" | LESSCHARSET="$charset" less -k "$LESSKEY" +k -R
+ esac < "$pagefile" | LESSCHARSET="$charset" less -k "$LESSKEY" +k -R
code="$?"
- rm "$cachedir/curpage"
+ rm "$pagefile"
# Choose what to do next
debug "pager exit code: $code"