readwwwlog: Don't open terminal if already in terminal

This commit is contained in:
tastytea 2022-04-15 14:48:54 +02:00
parent cf6d630911
commit 837077ea39
Signed by: tastytea
SSH Key Fingerprint: SHA256:FBkvrOlhq5use1XEttyUGT4bUTDVA1ar9SgIc9P03cM

View File

@ -30,8 +30,13 @@ for url in ${urls}; do
sleep 1 # dpaste.com workaround
local file="$(mktemp --suffix='.readwwwlog')"
curl --silent --location --output ${file} ${url}
${TERMINAL} ${termopts} -e \
less --LINE-NUMBERS --pattern='(error|fail):' ${file}
local -a cmd=(less --LINE-NUMBERS --pattern='(error|fail):' ${file})
if [[ -o NO_INTERACTIVE ]]; then
cmd=(${TERMINAL} ${termopts} -e ${cmd})
fi
${cmd}
rm ${file}
else
${default_cmd} ${url}