diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2023-06-08 13:19:57 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2023-06-08 13:19:57 -0400 |
commit | 1d1443193878ae72e54560bb21de79668cd954b9 (patch) | |
tree | d3ceedfe927061594f3238bd7edf22d29e6c9d6d | |
parent | 4c2d7e8271a35409acaba228968ab7641397bbe6 (diff) | |
download | bfs-1d1443193878ae72e54560bb21de79668cd954b9.tar.xz |
color: `fi=0` should not fall back to `no`
-rw-r--r-- | src/color.c | 8 | ||||
-rw-r--r-- | tests/bfs/color_cd0_no.out | 20 | ||||
-rw-r--r-- | tests/bfs/color_cd0_no.sh | 1 | ||||
-rw-r--r-- | tests/bfs/color_fi0_no.out | 20 | ||||
-rw-r--r-- | tests/bfs/color_fi0_no.sh | 1 | ||||
-rw-r--r-- | tests/bfs/color_fi_no.out | 20 | ||||
-rw-r--r-- | tests/bfs/color_fi_no.sh | 1 | ||||
-rw-r--r-- | tests/bfs/color_no.out | 20 | ||||
-rw-r--r-- | tests/bfs/color_no.sh | 1 |
9 files changed, 88 insertions, 4 deletions
diff --git a/src/color.c b/src/color.c index a723084..87575c9 100644 --- a/src/color.c +++ b/src/color.c @@ -436,10 +436,11 @@ struct colors *parse_colors(void) { ret |= init_color(colors, "err", "01;31", &colors->error); // Defaults from man dir_colors + // "" means fall back to ->normal ret |= init_color(colors, "no", NULL, &colors->normal); - ret |= init_color(colors, "fi", NULL, &colors->file); + ret |= init_color(colors, "fi", "", &colors->file); ret |= init_color(colors, "mh", NULL, &colors->multi_hard); ret |= init_color(colors, "ex", "01;32", &colors->executable); ret |= init_color(colors, "ca", NULL, &colors->capable); @@ -472,8 +473,7 @@ struct colors *parse_colors(void) { if (colors->link && strcmp(colors->link, "target") == 0) { colors->link_as_target = true; - dstrfree(colors->link); - colors->link = NULL; + dstresize(&colors->link, 0); } return colors; @@ -634,7 +634,7 @@ static const char *file_color(const struct colors *colors, const char *filename, break; } - if (!color) { + if (color && !color[0]) { color = colors->normal; } diff --git a/tests/bfs/color_cd0_no.out b/tests/bfs/color_cd0_no.out new file mode 100644 index 0000000..d5c98a9 --- /dev/null +++ b/tests/bfs/color_cd0_no.out @@ -0,0 +1,20 @@ +[01;34mrainbow[0m +[01;34mrainbow/[0m[01;32mexec.sh[0m +[01;34mrainbow/[0m[01;35msocket[0m +[01;34mrainbow/[0m[01;92mbroken[0m +[01;34mrainbow/[0m[01;92mfile.dat[0m +[01;34mrainbow/[0m[01;92mfile.txt[0m +[01;34mrainbow/[0m[01;92mlink.txt[0m +[01;34mrainbow/[0m[01;92mmh1[0m +[01;34mrainbow/[0m[01;92mmh2[0m +[01;34mrainbow/[0m[01;92mstar.gz[0m +[01;34mrainbow/[0m[01;92mstar.tar[0m +[01;34mrainbow/[0m[01;92mstar.tar.gz[0m +[01;34mrainbow/[0m[30;42msticky_ow[0m +[01;34mrainbow/[0m[30;43msgid[0m +[01;34mrainbow/[0m[33mpipe[0m +[01;34mrainbow/[0m[34;42mow[0m +[01;34mrainbow/[0m[37;41msugid[0m +[01;34mrainbow/[0m[37;41msuid[0m +[01;34mrainbow/[0m[37;44msticky[0m +[01;34mrainbow/[0mchardev_link diff --git a/tests/bfs/color_cd0_no.sh b/tests/bfs/color_cd0_no.sh new file mode 100644 index 0000000..325a782 --- /dev/null +++ b/tests/bfs/color_cd0_no.sh @@ -0,0 +1 @@ +LS_COLORS="ln=target:cd=0:no=01;92:" bfs_diff rainbow -color diff --git a/tests/bfs/color_fi0_no.out b/tests/bfs/color_fi0_no.out new file mode 100644 index 0000000..77fc8a8 --- /dev/null +++ b/tests/bfs/color_fi0_no.out @@ -0,0 +1,20 @@ +[01;34mrainbow[0m +[01;34mrainbow/[0m[01;32mexec.sh[0m +[01;34mrainbow/[0m[01;35msocket[0m +[01;34mrainbow/[0m[01;36mbroken[0m +[01;34mrainbow/[0m[01;36mchardev_link[0m +[01;34mrainbow/[0m[01;36mlink.txt[0m +[01;34mrainbow/[0m[30;42msticky_ow[0m +[01;34mrainbow/[0m[30;43msgid[0m +[01;34mrainbow/[0m[33mpipe[0m +[01;34mrainbow/[0m[34;42mow[0m +[01;34mrainbow/[0m[37;41msugid[0m +[01;34mrainbow/[0m[37;41msuid[0m +[01;34mrainbow/[0m[37;44msticky[0m +[01;34mrainbow/[0mfile.dat +[01;34mrainbow/[0mfile.txt +[01;34mrainbow/[0mmh1 +[01;34mrainbow/[0mmh2 +[01;34mrainbow/[0mstar.gz +[01;34mrainbow/[0mstar.tar +[01;34mrainbow/[0mstar.tar.gz diff --git a/tests/bfs/color_fi0_no.sh b/tests/bfs/color_fi0_no.sh new file mode 100644 index 0000000..f947d64 --- /dev/null +++ b/tests/bfs/color_fi0_no.sh @@ -0,0 +1 @@ +LS_COLORS="fi=0:no=01;92:" bfs_diff rainbow -color diff --git a/tests/bfs/color_fi_no.out b/tests/bfs/color_fi_no.out new file mode 100644 index 0000000..7162ded --- /dev/null +++ b/tests/bfs/color_fi_no.out @@ -0,0 +1,20 @@ +[01;34mrainbow[0m +[01;34mrainbow/[0m[01;32mexec.sh[0m +[01;34mrainbow/[0m[01;35msocket[0m +[01;34mrainbow/[0m[01;36mbroken[0m +[01;34mrainbow/[0m[01;36mchardev_link[0m +[01;34mrainbow/[0m[01;36mlink.txt[0m +[01;34mrainbow/[0m[01;91mfile.dat[0m +[01;34mrainbow/[0m[01;91mfile.txt[0m +[01;34mrainbow/[0m[01;91mmh1[0m +[01;34mrainbow/[0m[01;91mmh2[0m +[01;34mrainbow/[0m[01;91mstar.gz[0m +[01;34mrainbow/[0m[01;91mstar.tar[0m +[01;34mrainbow/[0m[01;91mstar.tar.gz[0m +[01;34mrainbow/[0m[30;42msticky_ow[0m +[01;34mrainbow/[0m[30;43msgid[0m +[01;34mrainbow/[0m[33mpipe[0m +[01;34mrainbow/[0m[34;42mow[0m +[01;34mrainbow/[0m[37;41msugid[0m +[01;34mrainbow/[0m[37;41msuid[0m +[01;34mrainbow/[0m[37;44msticky[0m diff --git a/tests/bfs/color_fi_no.sh b/tests/bfs/color_fi_no.sh new file mode 100644 index 0000000..c2b4ec7 --- /dev/null +++ b/tests/bfs/color_fi_no.sh @@ -0,0 +1 @@ +LS_COLORS="fi=01;91:no=01;92:" bfs_diff rainbow -color diff --git a/tests/bfs/color_no.out b/tests/bfs/color_no.out new file mode 100644 index 0000000..9f0dd66 --- /dev/null +++ b/tests/bfs/color_no.out @@ -0,0 +1,20 @@ +[01;34mrainbow[0m +[01;34mrainbow/[0m[01;32mexec.sh[0m +[01;34mrainbow/[0m[01;35msocket[0m +[01;34mrainbow/[0m[01;36mbroken[0m +[01;34mrainbow/[0m[01;36mchardev_link[0m +[01;34mrainbow/[0m[01;36mlink.txt[0m +[01;34mrainbow/[0m[01;92mfile.dat[0m +[01;34mrainbow/[0m[01;92mfile.txt[0m +[01;34mrainbow/[0m[01;92mmh1[0m +[01;34mrainbow/[0m[01;92mmh2[0m +[01;34mrainbow/[0m[01;92mstar.gz[0m +[01;34mrainbow/[0m[01;92mstar.tar[0m +[01;34mrainbow/[0m[01;92mstar.tar.gz[0m +[01;34mrainbow/[0m[30;42msticky_ow[0m +[01;34mrainbow/[0m[30;43msgid[0m +[01;34mrainbow/[0m[33mpipe[0m +[01;34mrainbow/[0m[34;42mow[0m +[01;34mrainbow/[0m[37;41msugid[0m +[01;34mrainbow/[0m[37;41msuid[0m +[01;34mrainbow/[0m[37;44msticky[0m diff --git a/tests/bfs/color_no.sh b/tests/bfs/color_no.sh new file mode 100644 index 0000000..b7527cb --- /dev/null +++ b/tests/bfs/color_no.sh @@ -0,0 +1 @@ +LS_COLORS="no=01;92:" bfs_diff rainbow -color |