geminish/gemini_get_openssl.sh

28 lines
854 B
Bash
Executable File

#!/bin/sh
#i="gemini://gemini.circumlunar.space/" #you can set i in scripts environment, like i="asd" gemini_get_openssl.sh
# checks url in order of: env variable, then command argument, then stdin
if [ -z "$i" ];then
if [ -n "$1" ];then #if command-line argument
i="$1"
else #ask user
printf "gemini:// URL: " >&2;
read -r i;
fi
fi
if [ -n "$i" ];then
echo "$i"|cut -d / -f 3-|{
read -r a
domain="$(echo "$a"|cut -d / -f 1)"
url="$(echo "$a"|cut -d / -f 2-)"
printf "%s\r\n" "gemini://$domain/$url"|
#it will still have a lil warning on self-signed certs
openssl s_client -connect "$domain":1965 -quiet -verify_quiet \
2>/dev/null
#2>&1|sed "\$s/^read:errno=0\$//"
#^stderr ignoring, or, stderr combining with stdout and filtering the normal-end
}
else
echo "no gemini:// url detected!"
fi
i="" #other ways to unset it too