-
Notifications
You must be signed in to change notification settings - Fork 0
/
rtr_funs.sh
36 lines (30 loc) · 1016 Bytes
/
rtr_funs.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
retrier_sh ()
{
works_f="${1:-works}" &&
retried="${2:-0}" &&
export -- works_f retried && export -f -- retrier_sh "$works_f" &&
"$works_f" &&
{ echo :succ :: "$works_f" ,,, "$retried" >&2 ; } ||
{ echo :fail :: "$works_f" ,,, "$retried" >&2 ; exec sh -c ' retrier_sh "$works_f" "$((retried+1))" ' ; } ;
} ;
retrier ()
{
works_f="${1:-works}" &&
retried="${2:-0}" &&
"$works_f" &&
{ echo :succ :: "$works_f" ,,, "$retried" >&2 ; } ||
{ echo :fail :: "$works_f" ,,, "$retried" >&2 ; exec sh -c " $(declare -f -- retrier "$works_f") ; 'retrier' '$works_f' '$((retried+1))' " ; } ;
} ;
retrier_x ()
{
rtr ()
{
retried="${1:-0}" && shift &&
fun_name="${1:-fun}"
"$@" && { echo :succ :: "$fun_name" ,,, "$retried" >&2 ; } ||
{
echo :fail :: "$fun_name" ,,, "$retried" >&2 ;
exec sh -c "$(declare -f -- rtr "$fun_name") ; rtr '$((retried+1))' $* " ;
} ;
} && rtr 0 "$@" ;
} ;