File tree 4 files changed +30
-20
lines changed
4 files changed +30
-20
lines changed Original file line number Diff line number Diff line change @@ -165,25 +165,20 @@ usage() {
165
165
166
166
# Formating
167
167
168
- color () {
169
- local color=$1
170
- shift
171
- if [ -t 1 ] ; then echo -en " $color " ; fi
172
- if [ $# -gt 0 ]
173
- then
174
- echo $*
175
- else
176
- cat
177
- fi
178
- if [ -t 1 ] ; then echo -en " $NOCOLOR " ; fi
168
+ pretty_success () {
169
+ pretty_format " $GREEN " " \u2713" " $1 "
170
+ }
171
+
172
+ pretty_failure () {
173
+ pretty_format " $RED " " \u2717" " $1 "
179
174
}
180
175
181
176
pretty_format () {
182
177
local color=" $1 "
183
178
local pretty_symbol=" $2 "
184
179
local alt_symbol=" $3 "
185
180
local term_utf8=false
186
- if test -t 1 && [[ " $LANG " =~ .i * UTF-8.* ]]
181
+ if is_terminal && [[ " $LANG " =~ .* UTF-8.* ]]
187
182
then
188
183
term_utf8=true
189
184
fi
@@ -198,12 +193,27 @@ pretty_format() {
198
193
) | color " $color "
199
194
}
200
195
201
- pretty_success () {
202
- pretty_format " $GREEN " " \u2713" " $1 "
196
+ color () {
197
+ _start_color () {
198
+ if is_terminal ; then echo -en " $color " ; fi
199
+ }
200
+ _stop_color () {
201
+ if is_terminal ; then echo -en " $NOCOLOR " ; fi
202
+ }
203
+ local color=$1
204
+ shift
205
+ _start_color
206
+ if [ $# -gt 0 ]
207
+ then
208
+ echo $*
209
+ else
210
+ cat
211
+ fi
212
+ _stop_color
203
213
}
204
214
205
- pretty_failure () {
206
- pretty_format " $RED " " \u2717 " " $1 "
215
+ is_terminal () {
216
+ [ -t 1 ] || [[ " ${FORCE_COLOR} " == true ]]
207
217
}
208
218
209
219
text_format () {
Original file line number Diff line number Diff line change @@ -313,4 +313,4 @@ mute() {
313
313
notify_stderr () { echo -n ; }
314
314
}
315
315
316
- BASH_UNIT=../bash_unit
316
+ BASH_UNIT=" eval FORCE_COLOR=false ../bash_unit"
Original file line number Diff line number Diff line change 2
2
3
3
TEST_PATTERN=' ```bash|```test'
4
4
OUTPUT_PATTERN=' ```output'
5
- LANG=C
5
+ LANG=C.UTF-8
6
6
7
- BASH_UNIT=./bash_unit
7
+ BASH_UNIT=" eval FORCE_COLOR=false ./bash_unit"
8
8
9
9
prepare_tests () {
10
10
mkdir /tmp/$$
Original file line number Diff line number Diff line change @@ -91,4 +91,4 @@ bash_unit_out_for_code() {
91
91
$BASH_UNIT -f tap <( cat) | sed -e ' s:/dev/fd/[0-9]*:code:g'
92
92
}
93
93
94
- BASH_UNIT=../bash_unit
94
+ BASH_UNIT=" eval FORCE_COLOR=false ../bash_unit"
You can’t perform that action at this time.
0 commit comments