VirtualBox

source: kBuild/vendor/grep/2.12/tests/include-exclude@ 3627

Last change on this file since 3627 was 2595, checked in by bird, 13 years ago

gnu grep version 2.12 (grep-2.12.tar.xz, md5sum=8d2f0346d08b13c18afb81f0e8aa1e2f)

File size: 1.7 KB
Line 
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
5mkdir -p x/dir || framework_failure_
6echo aaa > x/a || framework_failure_
7echo bbb > x/b || framework_failure_
8echo ddd > x/dir/d || framework_failure_
9
10printf '%s\n' x/b:bbb x/dir/d:ddd > exp-not-a || framework_failure_
11printf '%s\n' x/dir/d:ddd > exp-not-ab || framework_failure_
12printf '%s\n' x/a:aaa x/b:bbb > exp-not-d || framework_failure_
13printf '%s\n' x/a:aaa x/b:bbb > exp-not-dir || framework_failure_
14printf '%s\n' x/a:aaa > exp-a || framework_failure_
15printf '%s\n' a:aaa > exp-aa || framework_failure_
16printf '%s\n' aaa > exp-aaa || framework_failure_
17
18grep -r --exclude='a*' . x > out || fail=1
19sort out > k && mv k out
20compare exp-not-a out || fail=1
21
22grep -r --exclude='[ab]' . x > out || fail=1
23sort out > k && mv k out
24compare exp-not-ab out || fail=1
25
26grep -r --exclude='*d' . x > out || fail=1
27sort out > k && mv k out
28compare exp-not-d out || fail=1
29
30grep -r --exclude-dir=dir . x > out || fail=1
31sort out > k && mv k out
32compare exp-not-dir out || fail=1
33
34# Test with a non-glob.
35grep -r --include=a . x > out || fail=1
36# no need to sort
37compare exp-a out || fail=1
38
39# Also test --include with a "glob".
40grep -r --include='a*' . x > out || fail=1
41# no need to sort
42compare exp-a out || fail=1
43
44# --include (without --recursive) uses different code
45grep --directories=skip --include=a --exclude-dir=dir '^aaa$' x/* > out || fail=1
46compare exp-a out || fail=1
47
48(cd x && grep -r --exclude-dir=. '^aaa$') > out || fail=1
49compare exp-aa out || fail=1
50
51grep --exclude=- '^aaa$' - < x/a > out || fail=1
52compare exp-aaa out || fail=1
53
54Exit $fail
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette