5 # List ignored files of current directory by constructing a "find"
6 # expression that matches names of ignored files.
8 # This script supports a reasonable subset of "gitignore(5)"
9 # semantics. Notably, it does support:
10 # * Patterns read from .gitignore files in current and parent directories
11 # * Blank line separators
12 # * Leading "#" comments
13 # * Trailing "/" directory patterns
14 # * Leading "/" this-directory patterns
15 # and it does not support:
16 # * Patterns read from $GIT_DIR/info/exclude
17 # (b/c inappropriate for a source release)
18 # * Patterns read from file specified by configuration variable core.excludesfile
19 # (b/c inappropriate for a source release)
20 # * Leading "!" negation patterns
21 # (b/c complex semantics)
22 # * Internal "/" FNM_PATHNAME patterns
23 # (b/c complex semantics incompatible with '-path' primary)
27 root
=$
(cd "$dir/.." && pwd)
38 if [ -r "$idir/$ignore" ]; then
39 while IFS
= read -r opat
; do
41 ## Blank line: Separator -- supported
42 if [ -z "$pat" ]; then
45 ## Leading "#": Comment -- supported
46 if [ "${pat:0:1}" = "#" ]; then
49 ## Leading "\#": Pattern beginning with "#" -- supported
50 if [ "${pat:0:2}" = "\#" ]; then
53 ## Leading "!": Negated pattern -- unsupported
54 if [ "${pat:0:1}" = "!" ]; then
55 echo "$name:: unsupported pattern: $opat"
58 ## Leading "\!": Pattern beginning with "!" -- supported
59 if [ "${pat:0:2}" = "\!" ]; then
62 ## Trailing "/": Directory pattern -- supported
63 if [ "${pat:$((${#pat}-1)):1}" = "/" ]; then
65 pat
="${pat:0:$((${#pat}-1))}"
69 ## Leading "/": This-directory pattern -- supported
70 if [ "${pat:0:1}" = "/" ]; then
71 if [ "$idir" = "." ]; then
77 ## Internal "/": FNM_PATHNAME pattern -- unsupported
78 if [ -z "${pat##*/*}" ]; then
79 echo "$name:: unsupported pattern: $opat"
84 if [ "$dirPat" = "yes" ]; then
91 done < "$idir/$ignore"
93 if [ "$(cd "$idir" && pwd)" != "$root" ]; then
101 find .
-mindepth 1 -maxdepth 1 "${fargs[@]}" -print