summaryrefslogtreecommitdiffstats
path: root/tests/find-color.sh
blob: 47de2a241b7bf93033d1a59c61edfb2a52483403 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env bash

# Copyright © Tavian Barnes <tavianator@tavianator.com>
# SPDX-License-Identifier: 0BSD

set -e

L=
COLOR=
ARGS=()
for ARG; do
    case "$ARG" in
        -L)
            L="$ARG"
            ;;
        -color)
            COLOR=y
            ;;
        *)
            ARGS+=("$ARG")
            ;;
    esac
done

LS_COLOR="${BASH_SOURCE%/*}/ls-color.sh"

if [ "$COLOR" ]; then
    find "${ARGS[@]}" -exec "$LS_COLOR" $L {} \;
else
    find "${ARGS[@]}"
fi