|
1 | | -seed=$(date +%s) |
2 | | -# seed=${SEED:-$EPOCHSECONDS} |
3 | | - |
4 | | -# setup_output() { |
5 | | - |
6 | | -# # already initialized? -> do nothing |
7 | | -# [ -n "${_msolve_test_output:-}" ] && return |
8 | | -# _msolve_test_output=1 |
9 | | - |
10 | | -# # defaults (safe for logs / CI / pipes) |
11 | | -# isatty=0 |
12 | | -# use_color=0 |
13 | | -# use_cr=0 |
14 | | - |
15 | | -# # No colored output (default) |
16 | | -# colseed="" |
17 | | -# colexit="" |
18 | | -# std="" |
19 | | - |
20 | | -# # Last character after normal exit |
21 | | -# lastcharexit="\n" |
22 | | - |
23 | | -# # Detect terminal on stderr (diagnostics channel) |
24 | | -# if [ -t 2 ] && [ -n "$TERM" ] && [ "$TERM" != dumb ]; then |
25 | | -# isatty=1 |
26 | | -# use_color=1 |
27 | | -# use_cr=1 |
28 | | -# fi |
29 | | - |
30 | | -# # Colored output |
31 | | -# if [ "$use_color" -eq 1 ]; then |
32 | | -# # colseed='\033[0;96m' # High Intensity Light blue. |
33 | | -# colseed=$(tput setaf 14) # High Intensity Light blue. |
34 | | -# # colexit='\033[0;93m' # High Intensity Yellow. |
35 | | -# colexit=$(tput setaf 11) # High Intensity Yellow. |
36 | | -# # std='\033[0m' |
37 | | -# std=$(tput sgr0) |
38 | | -# fi |
39 | | - |
40 | | -# # Carriage return afer normal exit |
41 | | -# if [ "$use_cr" -eq 1 ]; then |
42 | | -# lastcharexit="\r" |
43 | | -# fi |
44 | | -# } |
| 1 | +seed=${SEED:-$(date +%s)} |
| 2 | + |
| 3 | +setup_output() { |
| 4 | + |
| 5 | + # already initialized? -> do nothing |
| 6 | + [ -n "${_msolve_test_output:-}" ] && return |
| 7 | + _msolve_test_output=1 |
| 8 | + |
| 9 | + # defaults (safe for logs / CI / pipes) |
| 10 | + isatty=0 |
| 11 | + use_color=0 |
| 12 | + use_cr=0 |
| 13 | + |
| 14 | + # No colored output (default) |
| 15 | + colseed="" |
| 16 | + colexit="" |
| 17 | + std="" |
| 18 | + |
| 19 | + # Last character after normal exit |
| 20 | + lastcharexit="\n" |
| 21 | + |
| 22 | + # Detect terminal on stderr (diagnostics channel) |
| 23 | + if [ -t 2 ] && [ -n "$TERM" ] && [ "$TERM" != dumb ]; then |
| 24 | + isatty=1 |
| 25 | + use_color=1 |
| 26 | + use_cr=1 |
| 27 | + fi |
| 28 | + |
| 29 | + # Colored output |
| 30 | + if [ "$use_color" -eq 1 ]; then |
| 31 | + # colseed='\033[0;96m' # High Intensity Light blue. |
| 32 | + colseed=$(tput setaf 14) # High Intensity Light blue. |
| 33 | + # colexit='\033[0;93m' # High Intensity Yellow. |
| 34 | + colexit=$(tput setaf 11) # High Intensity Yellow. |
| 35 | + # std='\033[0m' |
| 36 | + std=$(tput sgr0) |
| 37 | + fi |
| 38 | + |
| 39 | + # Carriage return afer normal exit |
| 40 | + if [ "$use_cr" -eq 1 ]; then |
| 41 | + lastcharexit="\r" |
| 42 | + fi |
| 43 | +} |
45 | 44 |
|
46 | 45 | # print the seed in color |
47 | 46 | print_seed() { |
48 | | - printf "SEED $seed\n" >&2 |
| 47 | + setup_output |
| 48 | + printf "${beforeseed}${colseed}SEED${std}: %-10d " $seed >&2 |
49 | 49 | } |
50 | 50 |
|
51 | | - |
52 | | -# print_seed() { |
53 | | -# setup_output |
54 | | -# printf "${beforeseed}${colseed}SEED${std}: %-10d " $seed >&2 |
55 | | -# } |
56 | | - |
57 | 51 | print_seed |
58 | 52 |
|
59 | 53 | # print a last character depending on the output stream |
60 | 54 | normal_exit() { |
61 | | - : |
| 55 | + printf "$lastcharexit" >&2 |
62 | 56 | } |
63 | 57 |
|
64 | | -# normal_exit() { |
65 | | -# printf "$lastcharexit" >&2 |
66 | | -# } |
67 | | - |
68 | 58 |
|
69 | 59 | # print the exit code in color |
70 | 60 | print_exit() { |
71 | 61 | local excode=$1 |
72 | | - printf "EXIT: $excode\n" >&2 |
| 62 | + printf "${colexit}EXIT${std}: $excode\n" >&2 |
73 | 63 | exit "$excode" |
74 | 64 | } |
75 | 65 |
|
76 | | -# print_exit() { |
77 | | -# local excode=$1 |
78 | | -# printf "${colexit}EXIT${std}: $excode\n" >&2 |
79 | | -# exit "$excode" |
80 | | -# } |
81 | | - |
82 | 66 | # each diff_example.sh is built by running msolve on $file.ms |
83 | 67 | # with options -L 0 -l 2 -t 1 |
84 | 68 | # if the execution fails, print_exit 1 |
|
0 commit comments