File: include-exclude

package info (click to toggle)
grep 2.6.3-3%2Bsqueeze1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 8,368 kB
  • ctags: 4,688
  • sloc: ansic: 15,006; sh: 8,554; makefile: 210; awk: 71; sed: 16
file content (43 lines) | stat: -rw-r--r-- 1,295 bytes parent folder | download
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
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/sh
# Use of any --include or --exclude* option would segfault in 2.6 and 2.6.1
: ${srcdir=.}
. "$srcdir/init.sh"; path_prepend_ ../src

mkdir -p x/dir || framework_failure_
echo a > x/a || framework_failure_
echo b > x/b || framework_failure_
echo d > x/dir/d || framework_failure_

printf '%s\n' x/b:b x/dir/d:d > exp-not-a   || framework_failure_
printf '%s\n'       x/dir/d:d > exp-not-ab  || framework_failure_
printf '%s\n' x/a:a x/b:b     > exp-not-d   || framework_failure_
printf '%s\n' x/a:a x/b:b     > exp-not-dir || framework_failure_
printf '%s\n' x/a:a           > exp-a       || framework_failure_

grep -r --exclude='a*'    . x > out || fail=1
sort out > k && mv k out
compare out exp-not-a || fail=1

grep -r --exclude='[ab]'  . x > out || fail=1
sort out > k && mv k out
compare out exp-not-ab || fail=1

grep -r --exclude='*d'    . x > out || fail=1
sort out > k && mv k out
compare out exp-not-d || fail=1

grep -r --exclude-dir=dir . x > out || fail=1
sort out > k && mv k out
compare out exp-not-dir || fail=1

# Test with a non-glob.
grep -r --include=a    . x > out || fail=1
# no need to sort
compare out exp-a || fail=1

# Also test --include with a "glob".
grep -r --include='a*'    . x > out || fail=1
# no need to sort
compare out exp-a || fail=1

Exit $fail