File tree Expand file tree Collapse file tree 4 files changed +30
-20
lines changed Expand file tree Collapse file tree 4 files changed +30
-20
lines changed Original file line number Diff line number Diff line change @@ -165,25 +165,20 @@ usage() {
165165
166166# Formating
167167
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 "
179174}
180175
181176pretty_format () {
182177 local color=" $1 "
183178 local pretty_symbol=" $2 "
184179 local alt_symbol=" $3 "
185180 local term_utf8=false
186- if test -t 1 && [[ " $LANG " =~ .i * UTF-8.* ]]
181+ if is_terminal && [[ " $LANG " =~ .* UTF-8.* ]]
187182 then
188183 term_utf8=true
189184 fi
@@ -198,12 +193,27 @@ pretty_format() {
198193 ) | color " $color "
199194}
200195
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
203213}
204214
205- pretty_failure () {
206- pretty_format " $RED " " \u2717 " " $1 "
215+ is_terminal () {
216+ [ -t 1 ] || [[ " ${FORCE_COLOR} " == true ]]
207217}
208218
209219text_format () {
Original file line number Diff line number Diff line change @@ -313,4 +313,4 @@ mute() {
313313 notify_stderr () { echo -n ; }
314314}
315315
316- BASH_UNIT=../bash_unit
316+ BASH_UNIT=" eval FORCE_COLOR=false ../bash_unit"
Original file line number Diff line number Diff line change 22
33TEST_PATTERN=' ```bash|```test'
44OUTPUT_PATTERN=' ```output'
5- LANG=C
5+ LANG=C.UTF-8
66
7- BASH_UNIT=./bash_unit
7+ BASH_UNIT=" eval FORCE_COLOR=false ./bash_unit"
88
99prepare_tests () {
1010 mkdir /tmp/$$
Original file line number Diff line number Diff line change @@ -91,4 +91,4 @@ bash_unit_out_for_code() {
9191 $BASH_UNIT -f tap <( cat) | sed -e ' s:/dev/fd/[0-9]*:code:g'
9292}
9393
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