summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/color.c8
-rw-r--r--tests/bfs/color_cd0_no.out20
-rw-r--r--tests/bfs/color_cd0_no.sh1
-rw-r--r--tests/bfs/color_fi0_no.out20
-rw-r--r--tests/bfs/color_fi0_no.sh1
-rw-r--r--tests/bfs/color_fi_no.out20
-rw-r--r--tests/bfs/color_fi_no.sh1
-rw-r--r--tests/bfs/color_no.out20
-rw-r--r--tests/bfs/color_no.sh1
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 @@
+rainbow
+rainbow/exec.sh
+rainbow/socket
+rainbow/broken
+rainbow/file.dat
+rainbow/file.txt
+rainbow/link.txt
+rainbow/mh1
+rainbow/mh2
+rainbow/star.gz
+rainbow/star.tar
+rainbow/star.tar.gz
+rainbow/sticky_ow
+rainbow/sgid
+rainbow/pipe
+rainbow/ow
+rainbow/sugid
+rainbow/suid
+rainbow/sticky
+rainbow/chardev_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 @@
+rainbow
+rainbow/exec.sh
+rainbow/socket
+rainbow/broken
+rainbow/chardev_link
+rainbow/link.txt
+rainbow/sticky_ow
+rainbow/sgid
+rainbow/pipe
+rainbow/ow
+rainbow/sugid
+rainbow/suid
+rainbow/sticky
+rainbow/file.dat
+rainbow/file.txt
+rainbow/mh1
+rainbow/mh2
+rainbow/star.gz
+rainbow/star.tar
+rainbow/star.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 @@
+rainbow
+rainbow/exec.sh
+rainbow/socket
+rainbow/broken
+rainbow/chardev_link
+rainbow/link.txt
+rainbow/file.dat
+rainbow/file.txt
+rainbow/mh1
+rainbow/mh2
+rainbow/star.gz
+rainbow/star.tar
+rainbow/star.tar.gz
+rainbow/sticky_ow
+rainbow/sgid
+rainbow/pipe
+rainbow/ow
+rainbow/sugid
+rainbow/suid
+rainbow/sticky
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 @@
+rainbow
+rainbow/exec.sh
+rainbow/socket
+rainbow/broken
+rainbow/chardev_link
+rainbow/link.txt
+rainbow/file.dat
+rainbow/file.txt
+rainbow/mh1
+rainbow/mh2
+rainbow/star.gz
+rainbow/star.tar
+rainbow/star.tar.gz
+rainbow/sticky_ow
+rainbow/sgid
+rainbow/pipe
+rainbow/ow
+rainbow/sugid
+rainbow/suid
+rainbow/sticky
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