File tree Expand file tree Collapse file tree 2 files changed +23
-28
lines changed Expand file tree Collapse file tree 2 files changed +23
-28
lines changed Original file line number Diff line number Diff line change @@ -13,36 +13,17 @@ std.find_parent_dir() {
13
13
std.util.find_parent -d " $1 "
14
14
}
15
15
16
- # @description Determine if color should be printed. Note that this doesn't
17
- # use tput because simple environment variable checking heuristics suffice
18
- std.should_output_color () {
19
- # https://no-color.org
20
- if [ ${NO_COLOR+x} ]; then
21
- return 1
22
- fi
23
-
24
- # FIXME
25
- # # 0 => 2 colors
26
- # # 1 => 16 colors
27
- # # 2 => 256 colors
28
- # # 3 => 16,777,216 colors
29
- # if [[ -v FORCE_COLOR ]]; then
30
- # return 0
31
- # fi
32
-
33
- if [ " $COLORTERM " = " truecolor" ] || [ " $COLORTERM " = " 24bit" ]; then
34
- return 0
35
- fi
36
16
37
- if [ " $TERM " = ' dumb' ]; then
38
- return 1
39
- fi
40
-
41
- if [ -t 0 ]; then
42
- return 0
43
- fi
17
+ # @description Determine if color should be printed to standard output
18
+ # @noargs
19
+ std.should_print_color_stdout () {
20
+ std.private.should_print_color 1
21
+ }
44
22
45
- return 1
23
+ # @description Determine if color should be printed to standard error
24
+ # @noargs
25
+ std.should_print_color_stderr () {
26
+ std.private.should_print_color 2
46
27
}
47
28
48
29
# @description Gets information from a particular package. If the key does not exist, then the value
Original file line number Diff line number Diff line change @@ -19,4 +19,18 @@ std.find_parent() {
19
19
) ; then : ; else
20
20
panic ' Failed to cd'
21
21
fi
22
+ }
23
+
24
+ std.private.should_print_color () {
25
+ local fd=" $1 "
26
+
27
+ if [[ ${NO_COLOR+x} || " $TERM " = ' dumb' ]]; then
28
+ return 1
29
+ fi
30
+
31
+ if [ -t " $fd " ]; then
32
+ return 0
33
+ fi
34
+
35
+ return 1
22
36
}
You can’t perform that action at this time.
0 commit comments