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