summaryrefslogtreecommitdiffstats
path: root/tests/ls-color.sh
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2023-10-19 16:37:47 -0400
committerTavian Barnes <tavianator@tavianator.com>2023-10-19 16:37:47 -0400
commit785a3f2d777627f39bed44f4ae7a0180d5184109 (patch)
tree2bee8cb669ab91982a7d6d1e8ada9958a2369ffd /tests/ls-color.sh
parentd484cba3424dcfca4851ba867d8877e3a9381a0e (diff)
downloadbfs-785a3f2d777627f39bed44f4ae7a0180d5184109.tar.xz
tests: Refactor implementation into separate files
Diffstat (limited to 'tests/ls-color.sh')
-rwxr-xr-xtests/ls-color.sh6
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/ls-color.sh b/tests/ls-color.sh
index 9fdd59c..b9a0402 100755
--- a/tests/ls-color.sh
+++ b/tests/ls-color.sh
@@ -7,7 +7,7 @@
set -e
-function parse_ls_colors() {
+parse_ls_colors() {
for key; do
local -n var="$key"
if [[ "$LS_COLORS" =~ (^|:)$key=(([^:]|\\:)*) ]]; then
@@ -18,7 +18,7 @@ function parse_ls_colors() {
done
}
-function re_escape() {
+re_escape() {
# https://stackoverflow.com/a/29613573/502399
sed 's/[^^]/[&]/g; s/\^/\\^/g' <<<"$1"
}
@@ -34,7 +34,7 @@ parse_ls_colors rs lc rc ec no
strip="(($(re_escape "$lc$no$rc"))?($(re_escape "$ec")|$(re_escape "$lc$rc")))+"
-function ls_color() {
+ls_color() {
# Strip the leading reset sequence from the ls output
ls -1d --color "$@" | sed -E "s/^$strip([a-z].*)$strip/\4/; s/^$strip//"
}