Skip to content

Commit da1090d

Browse files
author
Pascal Grange
committed
FIX problems when LANG is undefined
1 parent 05a2348 commit da1090d

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

README.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ Running tests in tests/test_core.sh
108108
Running test_fake_echo_stdin_when_no_params ... SUCCESS
109109
Running test_fake_exports_faked_in_subshells ... SUCCESS
110110
Running test_fake_transmits_params_to_fake_code ... SUCCESS
111+
Running test_should_pretty_format_even_when_LANG_is_unset ... SUCCESS
111112
Overall result: SUCCESS
112113
```
113114

@@ -166,6 +167,7 @@ ok - test_fake_can_fake_inline
166167
ok - test_fake_echo_stdin_when_no_params
167168
ok - test_fake_exports_faked_in_subshells
168169
ok - test_fake_transmits_params_to_fake_code
170+
ok - test_should_pretty_format_even_when_LANG_is_unset
169171
```
170172

171173
== How to write tests

bash_unit

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,10 @@ pretty_failure() {
233233
pretty_format() {
234234
local color="$1"
235235
local pretty_symbol="$2"
236-
local alt_symbol="$3"
236+
local alt_symbol="${3:-}"
237237
local term_utf8=false
238-
if is_terminal && [[ "$LANG" =~ .*UTF-8.* ]]
238+
#env
239+
if is_terminal && [[ "${LANG:-}" =~ .*UTF-8.* ]]
239240
then
240241
term_utf8=true
241242
fi
@@ -270,7 +271,7 @@ color() {
270271
}
271272

272273
is_terminal() {
273-
[ -t 1 ] || [[ "${FORCE_COLOR}" == true ]]
274+
[ -t 1 ] || [[ "${FORCE_COLOR:-}" == true ]]
274275
}
275276

276277
text_format() {

tests/test_core.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ EOF
138138
assert_equals 2 $(ps | "$GREP" pts | wc -l)
139139
}
140140

141+
test_should_pretty_format_even_when_LANG_is_unset() {
142+
# See https://github.com/pgrange/bash_unit/pull/81
143+
unset LANG
144+
assert "echo foo | pretty_format GREEN I"
145+
}
146+
141147
if [[ "${STICK_TO_CWD}" != true ]]
142148
then
143149
# do not test for cwd if STICK_TO_CWD is true

0 commit comments

Comments
 (0)