alox-jason 0.0.27 → 0.0.28
Sign up to get free protection for your applications and to get access to all the features.
- data/exec/_jason +134 -0
- data/exec/_log4sh +3842 -0
- data/exec/_shflags +1012 -0
- data/exec/_sub +56 -0
- metadata +6 -2
data/exec/_jason
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
function check_help {
|
4
|
+
# taken from shocco
|
5
|
+
if expr -- "$*" : ".*--help" >/dev/null; then
|
6
|
+
display_help
|
7
|
+
exit 0
|
8
|
+
fi
|
9
|
+
}
|
10
|
+
|
11
|
+
function require {
|
12
|
+
source "$@"
|
13
|
+
}
|
14
|
+
|
15
|
+
function parse_command_line {
|
16
|
+
if [[ "$FLAGS_SUB" = "$FLAGS_TRUE" && "$@" > 0 ]]; then
|
17
|
+
export POSIXLY_CORRECT=1
|
18
|
+
fi
|
19
|
+
|
20
|
+
if ! FLAGS "$@"; then
|
21
|
+
unset POSIXLY_CORRECT
|
22
|
+
if [[ "$flags_error" = "help requested" ]]; then
|
23
|
+
echo ""
|
24
|
+
display_help
|
25
|
+
exit 0
|
26
|
+
fi
|
27
|
+
|
28
|
+
return 4
|
29
|
+
fi
|
30
|
+
|
31
|
+
unset POSIXLY_CORRECT
|
32
|
+
return 0
|
33
|
+
}
|
34
|
+
|
35
|
+
function configure_logging {
|
36
|
+
if [[ -n "${NO_LOG4SH:-}" ]]; then
|
37
|
+
return 0
|
38
|
+
fi
|
39
|
+
|
40
|
+
LOG4SH_CONFIGURATION=none require _log4sh
|
41
|
+
|
42
|
+
log4sh_resetConfiguration
|
43
|
+
|
44
|
+
# set the global logging level to INFO
|
45
|
+
logger_setLevel INFO
|
46
|
+
|
47
|
+
# add and configure a FileAppender that outputs to STDERR, and activate the
|
48
|
+
# configuration
|
49
|
+
logger_addAppender stderr
|
50
|
+
appender_setType stderr FileAppender
|
51
|
+
appender_file_setFile stderr STDERR
|
52
|
+
appender_activateOptions stderr
|
53
|
+
}
|
54
|
+
|
55
|
+
function ryaml {
|
56
|
+
ruby -ryaml -e 'def ps x; unless x.nil?; puts (x.class == String || x.class == Fixnum) ? x : x.to_yaml; end; end; ps ARGV[1..-1].inject(YAML.load(File.read(ARGV[0]))) {|acc, key| acc[acc.class == Array ? key.to_i : (m = key.match(/^:(.*)$/); m ? m[1].to_sym : key)] }' "$@" 2>&-
|
57
|
+
}
|
58
|
+
|
59
|
+
function random_str {
|
60
|
+
echo "$(date +%s).$$.$RANDOM"
|
61
|
+
}
|
62
|
+
|
63
|
+
function runmany {
|
64
|
+
local cpu="$1"; shift
|
65
|
+
local args="$1"; shift
|
66
|
+
local cmd="$1"; shift
|
67
|
+
if [[ "$#" = 0 ]]; then
|
68
|
+
cat
|
69
|
+
else
|
70
|
+
echo "$@"
|
71
|
+
fi | xargs -P $cpu -n $args -- bash -c "$cmd" ""
|
72
|
+
}
|
73
|
+
|
74
|
+
function mark_log {
|
75
|
+
local nm_mark="$1"; shift
|
76
|
+
touch "$tmp_switch/wait-$nm_mark"
|
77
|
+
echo $tmp_switch $nm_mark
|
78
|
+
while [[ -f "$tmp_switch/wait-$nm_mark" ]]; do
|
79
|
+
sleep 1
|
80
|
+
done
|
81
|
+
}
|
82
|
+
|
83
|
+
function marked_logger {
|
84
|
+
local nm_switch=""
|
85
|
+
while read -r a b; do
|
86
|
+
if [[ "$a" = "$tmp_switch" ]]; then
|
87
|
+
nm_switch="$b"
|
88
|
+
rm "$tmp_switch/wait-$nm_switch"
|
89
|
+
else
|
90
|
+
if [[ -z "$nm_switch" ]]; then
|
91
|
+
echo "$a $b"
|
92
|
+
else
|
93
|
+
echo "$nm_switch: $a $b"
|
94
|
+
fi
|
95
|
+
fi
|
96
|
+
done
|
97
|
+
}
|
98
|
+
|
99
|
+
function mark_stdout {
|
100
|
+
if [[ -z "${tmp_switch:-}" ]]; then
|
101
|
+
tmp_switch="$(mktemp -d -t XXXXXXXXX)"
|
102
|
+
fi
|
103
|
+
exec 1> >(marked_logger)
|
104
|
+
}
|
105
|
+
|
106
|
+
function mark_stderr {
|
107
|
+
if [[ -z "${tmp_switch:-}" ]]; then
|
108
|
+
tmp_switch="$(mktemp -d -t XXXXXXXXX)"
|
109
|
+
fi
|
110
|
+
exec 2> >(marked_logger)
|
111
|
+
}
|
112
|
+
|
113
|
+
function mark_output {
|
114
|
+
if [[ -z "${tmp_switch:-}" ]]; then
|
115
|
+
tmp_switch="$(mktemp -d -t XXXXXXXXX)"
|
116
|
+
fi
|
117
|
+
exec 1> >(marked_logger) 2>&1
|
118
|
+
}
|
119
|
+
|
120
|
+
function _main {
|
121
|
+
: ${__jason__:=x}
|
122
|
+
if [[ "$__jason__" != 'x' ]]; then
|
123
|
+
return 0
|
124
|
+
fi
|
125
|
+
|
126
|
+
__jason__='y'
|
127
|
+
|
128
|
+
require _shflags
|
129
|
+
|
130
|
+
configure_logging
|
131
|
+
}
|
132
|
+
|
133
|
+
_main "$@"
|
134
|
+
set -fue
|