This commit is contained in:
Jack L. Frost 2015-01-17 16:44:04 +03:00
parent 94a38ffd73
commit fcb4c6bdb0

20
sup
View File

@ -4,18 +4,20 @@
# About:
# A simple upload script for ZFH (http://zerofiles.org)
_self="${0##*/}"
cfg_url_regex='^[A-Za-z]([A-Za-z0-9+.-]+)?://.+'
cfg_tmp_dir="/tmp/$USER/sup"; TEMPDIR="$cfg_tmp_dir"
cfg_script_url='https://zfh.so/upload'
cfg_screenshot_ext='png'
[[ -f $HOME/.suprc ]] && { source $HOME/.suprc; }
[[ -f $HOME/.suprc ]] && { source "$HOME/.suprc"; }
sup.msg() { echo "[sup] $1"; }
sup.err() { sup.msg "(error) $1" >&2; }
sup.usage() {
echo "Usage: `basename $0` [-RsF] [-D num] [file/url]"
echo "Usage: ${_self} [-RsF] [-D num] [file/url]"
}
sup.env() {
@ -49,7 +51,7 @@ sup.mktemp() {
sup.scrot() {
local tmp_file
[[ "$scrot_exec" ]] || { scrot_exec=`type -P scrot`; }
[[ "$scrot_exec" ]] || { scrot_exec=$(type -P scrot); }
[[ "$scrot_exec" ]] || {
sup.err "Please install scrot to use this function"
return 1
@ -98,15 +100,15 @@ sup.getopt() {
--*) echo "$i";;
-*)
keys=( `echo "${i##*-}" | fold -w1` )
keys=( $(echo "${i##*-}" | fold -w1) )
[[ "${#keys[@]}" -gt 1 ]] && {
for k in ${keys[@]}; do
if [[ "${#keys[@]}" -gt 1 ]]; then
for k in "${keys[@]}"; do
echo "-${k}"
done
} || {
else
echo "$i"
}
fi
;;
*) echo "$i";;
@ -143,7 +145,7 @@ main() {
target="${args[0]}"; [[ "$target" ]] || { sup.usage; exit 1; }
if sup.if_url "$target"; then
file=`sup.mktemp "$cfg_tmp_dir"`
file=$(sup.mktemp "$cfg_tmp_dir")
curl -skL "$target" > "$file" || {
sup.err "Could not download file."