#!/usr/bin/env bash has() { if (( $# )); then hash "$1" 2>/dev/null else return 1 fi } for prog in curl; do if ! has "$prog"; then printf 'please install %s\n' "$prog" >&2 exit 1 fi done declare -A opts while (( $# )); do case $1 in --*=*) key=${1#--} key=${key%%=*} val=${1#--"$key"=} opts[$key]=$val ;; --no-*) opts[${1#--no-}]=false ;; --) shift break ;; --*) opts[${1#--}]=true ;; *) break ;; esac shift done tail -n +1 -- "$@" | curl -sSA karahti/1.0 -w "%{redirect_url}" \ -F "paste_content=<-" -F "language=${opts[lang]:-auto}" \ -F "expiry=${opts[expire]}" https://p.ahti.space/nanopaste-get.cgi printf "\n"