| 1 | #!/bin/sh
|
|---|
| 2 | # Use of any --include or --exclude* option would segfault in 2.6 and 2.6.1
|
|---|
| 3 | . "${srcdir=.}/init.sh"; path_prepend_ ../src
|
|---|
| 4 |
|
|---|
| 5 | mkdir -p x/dir || framework_failure_
|
|---|
| 6 | echo aaa > x/a || framework_failure_
|
|---|
| 7 | echo bbb > x/b || framework_failure_
|
|---|
| 8 | echo ddd > x/dir/d || framework_failure_
|
|---|
| 9 |
|
|---|
| 10 | printf '%s\n' x/b:bbb x/dir/d:ddd > exp-not-a || framework_failure_
|
|---|
| 11 | printf '%s\n' x/dir/d:ddd > exp-not-ab || framework_failure_
|
|---|
| 12 | printf '%s\n' x/a:aaa x/b:bbb > exp-not-d || framework_failure_
|
|---|
| 13 | printf '%s\n' x/a:aaa x/b:bbb > exp-not-dir || framework_failure_
|
|---|
| 14 | printf '%s\n' x/a:aaa > exp-a || framework_failure_
|
|---|
| 15 | printf '%s\n' a:aaa > exp-aa || framework_failure_
|
|---|
| 16 | printf '%s\n' aaa > exp-aaa || framework_failure_
|
|---|
| 17 |
|
|---|
| 18 | grep -r --exclude='a*' . x > out || fail=1
|
|---|
| 19 | sort out > k && mv k out
|
|---|
| 20 | compare exp-not-a out || fail=1
|
|---|
| 21 |
|
|---|
| 22 | grep -r --exclude='[ab]' . x > out || fail=1
|
|---|
| 23 | sort out > k && mv k out
|
|---|
| 24 | compare exp-not-ab out || fail=1
|
|---|
| 25 |
|
|---|
| 26 | grep -r --exclude='*d' . x > out || fail=1
|
|---|
| 27 | sort out > k && mv k out
|
|---|
| 28 | compare exp-not-d out || fail=1
|
|---|
| 29 |
|
|---|
| 30 | grep -r --exclude-dir=dir . x > out || fail=1
|
|---|
| 31 | sort out > k && mv k out
|
|---|
| 32 | compare exp-not-dir out || fail=1
|
|---|
| 33 |
|
|---|
| 34 | # Test with a non-glob.
|
|---|
| 35 | grep -r --include=a . x > out || fail=1
|
|---|
| 36 | # no need to sort
|
|---|
| 37 | compare exp-a out || fail=1
|
|---|
| 38 |
|
|---|
| 39 | # Also test --include with a "glob".
|
|---|
| 40 | grep -r --include='a*' . x > out || fail=1
|
|---|
| 41 | # no need to sort
|
|---|
| 42 | compare exp-a out || fail=1
|
|---|
| 43 |
|
|---|
| 44 | # --include (without --recursive) uses different code
|
|---|
| 45 | grep --directories=skip --include=a --exclude-dir=dir '^aaa$' x/* > out || fail=1
|
|---|
| 46 | compare exp-a out || fail=1
|
|---|
| 47 |
|
|---|
| 48 | (cd x && grep -r --exclude-dir=. '^aaa$') > out || fail=1
|
|---|
| 49 | compare exp-aa out || fail=1
|
|---|
| 50 |
|
|---|
| 51 | grep --exclude=- '^aaa$' - < x/a > out || fail=1
|
|---|
| 52 | compare exp-aaa out || fail=1
|
|---|
| 53 |
|
|---|
| 54 | Exit $fail
|
|---|