Compare commits
4 Commits
dc03b5f577
...
53d5a31a30
| Author | SHA1 | Date | |
|---|---|---|---|
|
53d5a31a30
|
|||
|
1e0d54f5d6
|
|||
|
5d3004c87b
|
|||
|
14f3f2caf2
|
@@ -50,15 +50,14 @@ grep_match() {
|
||||
#usage To echo 1 if flag exists: arg f
|
||||
arg() {
|
||||
local need=${1:0:1} # argument to find (only first letter)
|
||||
[ $need ] || {
|
||||
[ "$need" ] || {
|
||||
echo "Argument is not specified!" >&2
|
||||
exit 1
|
||||
}
|
||||
local isflag=$2 || 0 # should we find the value or just the presence of the $need?
|
||||
local retvar=$3 || 0 # var to return value into (if 0 then value will be echo'ed in stdout)
|
||||
local args=(${__MAIN_ARGS[0]}) # args we need are stored in 1st element of __MAIN_ARGS
|
||||
for ((idx=0; idx<${#args[@]}; ++idx)) do # going through args
|
||||
local arg=${args[$idx]} # current argument
|
||||
for ((idx=0; idx<${#__MAIN_ARGS__[@]}; ++idx)) do # going through args
|
||||
local arg=${__MAIN_ARGS__[$idx]} # current argument
|
||||
# skip $arg if it starts with '--', letter or digit
|
||||
grep_match "$arg" "^(\w{1}|-{2})" && continue
|
||||
# clear $arg from special and duplicate characters
|
||||
@@ -67,15 +66,15 @@ arg() {
|
||||
# now we can check if $need is one of $chars
|
||||
if grep_match "-$need" "^-[$chars]$"; then # if it is
|
||||
if [[ $isflag = 1 ]]; then # and we expect it as a flag
|
||||
# then return '1' back into $3 (if exists) or echo in stdout
|
||||
[ $retvar ] && eval "$retvar='1'" || echo "1"
|
||||
# then return '1' back into $retvar (if exists) or echo in stdout
|
||||
[ "$retvar" ] && eval "$retvar='1'" || echo "1"
|
||||
else # but if $arg is not a flag
|
||||
# then get next argument as value of current one
|
||||
local value="${args[$idx+1]}"
|
||||
local value="${__MAIN_ARGS__[$idx+1]}"
|
||||
# check if it is valid value
|
||||
if grep_match "$value" "^\w+$"; then
|
||||
# and return it back back into $3 (if exists) or echo in stdout
|
||||
[ $retvar ] && eval "$retvar='$value'" || echo "$value"
|
||||
if grep_match "$value" "^[[:graph:]]+$"; then
|
||||
# and return it back back into $retvar (if exists) or echo in stdout
|
||||
[ "$retvar" ] && eval "$retvar='$value'" || echo "$value"
|
||||
break
|
||||
else # otherwise throw error message into stderr (just in case)
|
||||
echo "Argument '$arg' must have a correct value!" >&2
|
||||
@@ -98,28 +97,27 @@ arg() {
|
||||
#usage To echo 1 if flag exists: arg f
|
||||
argl() {
|
||||
local need=$1 # argument to find
|
||||
[ $need ] || {
|
||||
[ "$need" ] || {
|
||||
echo "Argument is not specified!" >&2
|
||||
exit 1
|
||||
}
|
||||
local isflag=$2 || 0 # should we find the value or just the presence of the $need?
|
||||
local retvar=$3 || 0 # var to return value into (if 0 then value will be echo'ed in stdout)
|
||||
local args=(${__MAIN_ARGS[0]}) # args we need are stored in 1st element of __MAIN_ARGS
|
||||
for ((idx=0; idx<${#args[@]}; ++idx)) do
|
||||
local arg=${args[$idx]} # current argument
|
||||
for ((idx=0; idx<${#__MAIN_ARGS__[@]}; ++idx)) do # going through args
|
||||
local arg=${__MAIN_ARGS__[$idx]} # current argument
|
||||
# if we expect $arg as a flag
|
||||
if [[ $isflag = 1 ]]; then
|
||||
# and if $arg has correct format (like '--flag')
|
||||
if grep_match "$arg" "^--$need"; then
|
||||
# then return '1' back into $3 (if exists) or echo in stdout
|
||||
[ ! $retvar = 0 ] && eval "$retvar=1" || echo "1"
|
||||
# then return '1' back into $retvar (if exists) or echo in stdout
|
||||
[ "$retvar" = 0 ] && echo "1" || eval "$retvar=1"
|
||||
break
|
||||
fi
|
||||
else # but if $arg is not a flag
|
||||
# check if $arg has correct format (like '--foo=bar')
|
||||
if grep_match "$arg" "^--$need=.+$"; then # if it is
|
||||
# then return part from '=' to arg's end as value back into $3 (if exists) or echo in stdout
|
||||
[ ! $retvar = 0 ] && eval "$retvar=${arg#*=}" || echo "${arg#*=}"
|
||||
# then return part from '=' to arg's end as value back into $retvar (if exists) or echo in stdout
|
||||
[ "$retvar" = 0 ] && echo "${arg#*=}" || eval "$retvar=${arg#*=}"
|
||||
break
|
||||
fi
|
||||
fi
|
||||
@@ -170,7 +168,7 @@ argn() {
|
||||
|
||||
# first we must save the original arguments passed
|
||||
# to the script when it was called:
|
||||
__MAIN_ARGS=$@
|
||||
__MAIN_ARGS__=($@)
|
||||
|
||||
echo -e "\n1. Short args (vars):"
|
||||
arg a 1 a # -a
|
||||
|
||||
@@ -85,3 +85,11 @@ cdownload() {
|
||||
require curl
|
||||
curl -fsSL "$1" -o "$2"
|
||||
}
|
||||
|
||||
is_int() {
|
||||
[[ "$1" =~ ^[0-9]+$ ]]
|
||||
}
|
||||
|
||||
is_number() {
|
||||
[[ "$1" =~ ^[0-9]+([.,][0-9]+)?$ ]]
|
||||
}
|
||||
|
||||
48
helpers/docker.sh
Normal file
48
helpers/docker.sh
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/bin/bash
|
||||
|
||||
########################################################
|
||||
# Docker wrappers
|
||||
########################################################
|
||||
|
||||
# Вызывает корректную команду docker compose
|
||||
docker.compose() {
|
||||
require docker
|
||||
|
||||
argl profiles 0 profiles
|
||||
args=${*/--profiles=[a-zA-Z_,0-9]*/}
|
||||
|
||||
if $(docker compose &>/dev/null); then
|
||||
local cmd="docker compose $args"
|
||||
elif installed_pkg "docker-compose"; then
|
||||
local cmd="docker-compose $args"
|
||||
warn
|
||||
warn "docker-compose v1 устарел и не поддерживается, его поведение непредсказуемо."
|
||||
warn "Обнови docker согласно документации: https://docs.docker.com/engine/install/"
|
||||
warn
|
||||
else
|
||||
error "Должен быть установлен docker-compose-plugin!"
|
||||
die "Установи docker согласно документации: https://docs.docker.com/engine/install/" 2
|
||||
fi
|
||||
|
||||
if [[ "$profiles" ]]; then
|
||||
export COMPOSE_PROFILES=$profiles
|
||||
debug "Выполнено: export COMPOSE_PROFILES=$profiles"
|
||||
fi
|
||||
|
||||
debug "Команда: $cmd"
|
||||
$cmd
|
||||
}
|
||||
|
||||
# Выводит информацию о контейнере
|
||||
docker.inspect() {
|
||||
cmd="docker inspect $*"
|
||||
debug "Команда: $cmd"
|
||||
$cmd 2>/dev/null
|
||||
}
|
||||
|
||||
# Выполняет команду в контейнере от имени root
|
||||
docker.exec() {
|
||||
cmd="docker exec -u root -it $*"
|
||||
debug "Команда: $cmd"
|
||||
$cmd
|
||||
}
|
||||
325
helpers/io.sh
325
helpers/io.sh
@@ -4,46 +4,49 @@
|
||||
# Simple and fancy input & output
|
||||
########################################################
|
||||
|
||||
IINFO="( i )"
|
||||
INOTE="( * )"
|
||||
IWARN="( # )"
|
||||
IERROR="( ! )"
|
||||
IFATAL="( @ )"
|
||||
ISUCCESS="( ! )"
|
||||
IASK="( ? )"
|
||||
IDEBUG="(DBG)"
|
||||
IVRB="( + )"
|
||||
which tput > /dev/null 2>&1 && [[ $(tput -T$TERM colors) -gt 8 ]] && CAN_USE_COLORS=1 || CAN_USE_COLORS=0
|
||||
USE_COLORS=${USE_COLORS:-$CAN_USE_COLORS}
|
||||
|
||||
BOLD="\e[1m"
|
||||
DIM="\e[2m"
|
||||
NOTBOLD="\e[22m" # sometimes \e[21m
|
||||
NOTDIM="\e[22m"
|
||||
NORMAL="\e[20m"
|
||||
RESET="\e[0m"
|
||||
[ $USE_COLORS = 1 ] && IINFO="( i )" || IINFO=''
|
||||
[ $USE_COLORS = 1 ] && INOTE="( * )" || INOTE=''
|
||||
[ $USE_COLORS = 1 ] && IWARN="( # )" || IWARN=''
|
||||
[ $USE_COLORS = 1 ] && IERROR="( ! )" || IERROR=''
|
||||
[ $USE_COLORS = 1 ] && IFATAL="( @ )" || IFATAL=''
|
||||
[ $USE_COLORS = 1 ] && ISUCCESS="( ! )" || ISUCCESS=''
|
||||
[ $USE_COLORS = 1 ] && IASK="( ? )" || IASK=''
|
||||
[ $USE_COLORS = 1 ] && IDEBUG="(DBG)" || IDEBUG=''
|
||||
[ $USE_COLORS = 1 ] && IVRB="( + )" || IVRB=''
|
||||
|
||||
FRESET="\e[39m"
|
||||
FBLACK="\e[30m"
|
||||
FWHITE="\e[97m"
|
||||
FRED="\e[31m"
|
||||
FGREEN="\e[32m"
|
||||
FYELLOW="\e[33m"
|
||||
FBLUE="\e[34m"
|
||||
FLRED="\e[91m"
|
||||
FLGREEN="\e[92m"
|
||||
FLYELLOW="\e[93m"
|
||||
FLBLUE="\e[94m"
|
||||
[ $USE_COLORS = 1 ] && BOLD="\e[1m" || BOLD=''
|
||||
[ $USE_COLORS = 1 ] && DIM="\e[2m" || DIM=''
|
||||
[ $USE_COLORS = 1 ] && NOTBOLD="\e[22m" || NOTBOLD='' # sometimes \e[21m
|
||||
[ $USE_COLORS = 1 ] && NOTDIM="\e[22m" || NOTDIM=''
|
||||
[ $USE_COLORS = 1 ] && NORMAL="\e[20m" || NORMAL=''
|
||||
[ $USE_COLORS = 1 ] && RESET="\e[0m" || RESET=''
|
||||
|
||||
BRESET="\e[49m"
|
||||
BBLACK="\e[40m"
|
||||
BWHITE="\e[107m"
|
||||
BRED="\e[41m"
|
||||
BGREEN="\e[42m"
|
||||
BYELLOW="\e[43m"
|
||||
BBLUE="\e[44m"
|
||||
BLRED="\e[101m"
|
||||
BLGREEN="\e[102m"
|
||||
BLYELLOW="\e[103m"
|
||||
BLBLUE="\e[104m"
|
||||
[ $USE_COLORS = 1 ] && FRESET="\e[39m" || FRESET=''
|
||||
[ $USE_COLORS = 1 ] && FBLACK="\e[30m" || FBLACK=''
|
||||
[ $USE_COLORS = 1 ] && FWHITE="\e[97m" || FWHITE=''
|
||||
[ $USE_COLORS = 1 ] && FRED="\e[31m" || FRED=''
|
||||
[ $USE_COLORS = 1 ] && FGREEN="\e[32m" || FGREEN=''
|
||||
[ $USE_COLORS = 1 ] && FYELLOW="\e[33m" || FYELLOW=''
|
||||
[ $USE_COLORS = 1 ] && FBLUE="\e[34m" || FBLUE=''
|
||||
[ $USE_COLORS = 1 ] && FLRED="\e[91m" || FLRED=''
|
||||
[ $USE_COLORS = 1 ] && FLGREEN="\e[92m" || FLGREEN=''
|
||||
[ $USE_COLORS = 1 ] && FLYELLOW="\e[93m" || FLYELLOW=''
|
||||
[ $USE_COLORS = 1 ] && FLBLUE="\e[94m" || FLBLUE=''
|
||||
|
||||
[ $USE_COLORS = 1 ] && BRESET="\e[49m" || BRESET=''
|
||||
[ $USE_COLORS = 1 ] && BBLACK="\e[40m" || BBLACK=''
|
||||
[ $USE_COLORS = 1 ] && BWHITE="\e[107m" || BWHITE=''
|
||||
[ $USE_COLORS = 1 ] && BRED="\e[41m" || BRED=''
|
||||
[ $USE_COLORS = 1 ] && BGREEN="\e[42m" || BGREEN=''
|
||||
[ $USE_COLORS = 1 ] && BYELLOW="\e[43m" || BYELLOW=''
|
||||
[ $USE_COLORS = 1 ] && BBLUE="\e[44m" || BBLUE=''
|
||||
[ $USE_COLORS = 1 ] && BLRED="\e[101m" || BLRED=''
|
||||
[ $USE_COLORS = 1 ] && BLGREEN="\e[102m" || BLGREEN=''
|
||||
[ $USE_COLORS = 1 ] && BLYELLOW="\e[103m" || BLYELLOW=''
|
||||
[ $USE_COLORS = 1 ] && BLBLUE="\e[104m" || BLBLUE=''
|
||||
|
||||
dt() {
|
||||
echo "[$(date +'%H:%M:%S')] "
|
||||
@@ -110,3 +113,251 @@ die() {
|
||||
# error 'test error'
|
||||
# fatal 'test fatal'
|
||||
# die 'test die'
|
||||
|
||||
# experiments ==============================================================================
|
||||
|
||||
# https://unix.stackexchange.com/a/269085
|
||||
# https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
|
||||
# https://linuxcommand.org/lc3_adv_tput.php
|
||||
# https://gist.github.com/dtmilano/4055d6df5b6e4ea87c5a72dc2d604193
|
||||
# https://gist.github.com/nick3499/402a6d7dccd474f2bdb679f4311b1238
|
||||
# https://gist.github.com/connorjan/2b02126868157c2b69f9aa0a052cdc86
|
||||
|
||||
# tput setaf 0
|
||||
# echo "BLACK FOREGROUND"
|
||||
# tput setaf 1
|
||||
# echo "RED FOREGROUND"
|
||||
# tput setaf 2
|
||||
# echo "GREEN FOREGROUND"
|
||||
# tput setaf 3
|
||||
# echo "YELLOW FOREGROUND"
|
||||
# tput setaf 4
|
||||
# echo "BLUE FOREGROUND"
|
||||
# tput setaf 5
|
||||
# echo "MAGENTA FOREGROUND"
|
||||
# tput setaf 6
|
||||
# echo "CYAN FOREGROUND"
|
||||
# tput setaf 7
|
||||
# echo "WHITE FOREGROUND"
|
||||
# tput reset
|
||||
|
||||
# ===========
|
||||
|
||||
# Text color - normal
|
||||
# fgblack="$(tput setaf 0)" # Black
|
||||
# fgred="$(tput setaf 1)" # Red
|
||||
# fggreen="$(tput setaf 2)" # Green
|
||||
# fgyellow="$(tput setaf 3)" # Yellow
|
||||
# fgblue="$(tput setaf 4)" # Blue
|
||||
# fgpurple="$(tput setaf 5)" # Purple
|
||||
# fgcyan="$(tput setaf 6)" # Cyan
|
||||
# fgwhite="$(tput setaf 7)" # White
|
||||
|
||||
# # Text color - bright
|
||||
# bfgblack="$(tput setaf 8)" # Black
|
||||
# bfgred="$(tput setaf 9)" # Red
|
||||
# bfggreen="$(tput setaf 10)" # Green
|
||||
# bfgyellow="$(tput setaf 11)" # Yellow
|
||||
# bfgblue="$(tput setaf 12)" # Blue
|
||||
# bfgpurple="$(tput setaf 13)" # Purple
|
||||
# bfgcyan="$(tput setaf 14)" # Cyan
|
||||
# bfgwhite="$(tput setaf 15)" # White
|
||||
|
||||
# # Background color - normal
|
||||
# bgblack="$(tput setab 0)" # Black - Background
|
||||
# bgred="$(tput setab 1)" # Red
|
||||
# bggreen="$(tput setab 2)" # Green
|
||||
# bgyellow="$(tput setab 3)" # Yellow
|
||||
# bgblue="$(tput setab 4)" # Blue
|
||||
# bgpurple="$(tput setab 5)" # Purple
|
||||
# bgcyan="$(tput setab 6)" # Cyan
|
||||
# bgwhite="$(tput setab 7)" # White
|
||||
|
||||
# # Background color - bright
|
||||
# bbgblack="$(tput setab 8)" # Black - Background - Bright
|
||||
# bbgred="$(tput setab 9)" # Red
|
||||
# bbggreen="$(tput setab 10)" # Green
|
||||
# bbgyellow="$(tput setab 11)" # Yellow
|
||||
# bbgblue="$(tput setab 12)" # Blue
|
||||
# bbgpurple="$(tput setab 13)" # Purple
|
||||
# bbgcyan="$(tput setab 14)" # Cyan
|
||||
# bbgwhite="$(tput setab 15)" # White
|
||||
|
||||
# # Other attributes
|
||||
# normal="$(tput sgr0)" # text reset
|
||||
# bold="$(tput bold)" # make bold
|
||||
# underline="$(tput smul)" # underline
|
||||
# nounderlin="$(tput rmul)" # remove underline
|
||||
# mkblink="$(tput blink)" # make blink
|
||||
# reverse="$(tput rev)" # reverse
|
||||
|
||||
# ===========
|
||||
|
||||
# tohex(){
|
||||
# dec=$(($1%256)) ### input must be a number in range 0-255.
|
||||
# if [ "$dec" -lt "16" ]; then
|
||||
# bas=$(( dec%16 ))
|
||||
# mul=128
|
||||
# [ "$bas" -eq "7" ] && mul=192
|
||||
# [ "$bas" -eq "8" ] && bas=7
|
||||
# [ "$bas" -gt "8" ] && mul=255
|
||||
# a="$(( (bas&1) *mul ))"
|
||||
# b="$(( ((bas&2)>>1)*mul ))"
|
||||
# c="$(( ((bas&4)>>2)*mul ))"
|
||||
# printf 'dec= %3s basic= #%02x%02x%02x\n' "$dec" "$a" "$b" "$c"
|
||||
# elif [ "$dec" -gt 15 ] && [ "$dec" -lt 232 ]; then
|
||||
# b=$(( (dec-16)%6 )); b=$(( b==0?0: b*40 + 55 ))
|
||||
# g=$(( (dec-16)/6%6)); g=$(( g==0?0: g*40 + 55 ))
|
||||
# r=$(( (dec-16)/36 )); r=$(( r==0?0: r*40 + 55 ))
|
||||
# printf 'dec= %3s color= #%02x%02x%02x\n' "$dec" "$r" "$g" "$b"
|
||||
# else
|
||||
# gray=$(( (dec-232)*10+8 ))
|
||||
# printf 'dec= %3s gray= #%02x%02x%02x\n' "$dec" "$gray" "$gray" "$gray"
|
||||
# fi
|
||||
# }
|
||||
|
||||
# for i in $(seq 0 255); do
|
||||
# tohex ${i}
|
||||
# done
|
||||
|
||||
# ===========
|
||||
|
||||
# fromhex(){
|
||||
# hex=${1#"#"}
|
||||
# r=$(printf '0x%0.2s' "$hex")
|
||||
# g=$(printf '0x%0.2s' ${hex#??})
|
||||
# b=$(printf '0x%0.2s' ${hex#????})
|
||||
# printf '%03d' "$(( (r<75?0:(r-35)/40)*6*6 +
|
||||
# (g<75?0:(g-35)/40)*6 +
|
||||
# (b<75?0:(b-35)/40) + 16 ))"
|
||||
# }
|
||||
|
||||
# fromhex 00fc7b
|
||||
|
||||
# ===========
|
||||
|
||||
# mode2header(){
|
||||
# #### For 16 Million colors use \e[0;38;2;R;G;Bm each RGB is {0..255}
|
||||
# printf '\e[mR\n' # reset the colors.
|
||||
# printf '\n\e[m%59s\n' "Some samples of colors for r;g;b. Each one may be 000..255"
|
||||
# printf '\e[m%59s\n' "for the ansi option: \e[0;38;2;r;g;bm or \e[0;48;2;r;g;bm :"
|
||||
# }
|
||||
|
||||
# mode2colors(){
|
||||
# # foreground or background (only 3 or 4 are accepted)
|
||||
# local fb="$1"
|
||||
# [[ $fb != 3 ]] && fb=4
|
||||
# local samples=(0 63 127 191 255)
|
||||
# for r in "${samples[@]}"; do
|
||||
# for g in "${samples[@]}"; do
|
||||
# for b in "${samples[@]}"; do
|
||||
# printf '\e[0;%s8;2;%s;%s;%sm%03d;%03d;%03d ' "$fb" "$r" "$g" "$b" "$r" "$g" "$b"
|
||||
# done; printf '\e[m\n'
|
||||
# done; printf '\e[m'
|
||||
# done; printf '\e[mReset\n'
|
||||
# }
|
||||
# mode2header
|
||||
# mode2colors 3
|
||||
# mode2colors 4
|
||||
|
||||
# ===========
|
||||
|
||||
# printf '\e[48;5;%dm ' {0..255}; printf '\e[0m \n'
|
||||
# for r in {200..255..5}; do
|
||||
# fb=4
|
||||
# g=1
|
||||
# b=1
|
||||
# printf '\e[0;%s8;2;%s;%s;%sm ' "$fb" "$r" "$g" "$b"
|
||||
# done
|
||||
# echo
|
||||
|
||||
# ===========
|
||||
|
||||
# color(){
|
||||
# for c; do
|
||||
# printf '\e[48;5;%dm%03d' $c $c
|
||||
# done
|
||||
# printf '\e[0m \n'
|
||||
# }
|
||||
|
||||
# IFS=$' \t\n'
|
||||
# color {0..15}
|
||||
# for ((i=0;i<6;i++)); do
|
||||
# color $(seq $((i*36+16)) $((i*36+51)))
|
||||
# done
|
||||
# color {232..255}
|
||||
|
||||
# ===========
|
||||
|
||||
# for ((i=0; i<256; i++)) ;do
|
||||
# echo -n ' '
|
||||
# tput setab $i
|
||||
# tput setaf $(( ( (i>231&&i<244 ) || ( (i<17)&& (i%8<2)) ||
|
||||
# (i>16&&i<232)&& ((i-16)%6 <(i<100?3:2) ) && ((i-16)%36<15) )?7:16))
|
||||
# printf " C %03d " $i
|
||||
# tput op
|
||||
# (( ((i<16||i>231) && ((i+1)%8==0)) || ((i>16&&i<232)&& ((i-15)%6==0)) )) &&
|
||||
# printf "\n" ''
|
||||
# done
|
||||
|
||||
# ===========
|
||||
|
||||
# echo "tput character test"
|
||||
# echo "==================="
|
||||
# echo
|
||||
|
||||
# tput bold; echo "This text has the bold attribute."; tput sgr0
|
||||
|
||||
# tput smul; echo "This text is underlined (smul)."; tput rmul
|
||||
|
||||
# # Most terminal emulators do not support blinking text (though xterm
|
||||
# # does) because blinking text is considered to be in bad taste ;-)
|
||||
# tput blink; echo "This text is blinking (blink)."; tput sgr0
|
||||
|
||||
# tput rev; echo "This text has the reverse attribute"; tput sgr0
|
||||
|
||||
# # Standout mode is reverse on many terminals, bold on others.
|
||||
# tput smso; echo "This text is in standout mode (smso)."; tput rmso
|
||||
|
||||
# tput sgr0
|
||||
# echo
|
||||
|
||||
|
||||
# experiments ==============================================================================
|
||||
|
||||
# function delay_spinner(){
|
||||
# ##
|
||||
# ## Usage:
|
||||
# ##
|
||||
# ## $ long-running-command &
|
||||
# ## $ delay_spinner " Please wait msg..."
|
||||
# ##
|
||||
# ## Spinner exists when long-running-command completes
|
||||
# ##
|
||||
# local PROGRESSTXT
|
||||
# if [ ! "$1" ]; then
|
||||
# PROGRESSTXT=" Please wait..."
|
||||
# else
|
||||
# PROGRESSTXT="$1"
|
||||
# fi
|
||||
# # visual progress marker function
|
||||
# # http://stackoverflow.com/users/2869509/wizurd
|
||||
# # vars
|
||||
# local pid=$!
|
||||
# local delay=0.1
|
||||
# local spinstr='|/-\'
|
||||
# echo -e "\n\n"
|
||||
# while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do
|
||||
# local temp=${spinstr#?}
|
||||
# printf "\r$PROGRESSTXT[%c] " "$spinstr"
|
||||
# local spinstr=$temp${spinstr%"$temp"}
|
||||
# sleep $delay
|
||||
# printf "\b\b\b\b\b\b"
|
||||
# done
|
||||
# printf -- '\n\n'
|
||||
# #
|
||||
# # <-- end function ec2cli_spinner -->
|
||||
# #
|
||||
# }
|
||||
# sleep 10 && echo 'test' &
|
||||
# delay_spinner "Please wait msg..."
|
||||
|
||||
Reference in New Issue
Block a user